█████████ ████ ███░░░░░███ ░░███ ███ ░░░ ██████ ███████ ██████ ██████ ░███ ███░░███ ███░░███ ███░░███ ███░░███ ░███ ░███ ░███░███ ░███ ░███████ ░███ ░███ ░░███ ███░███ ░███░███ ░███ ░███░░░ ░███ ░███ ░░█████████ ░░██████ ░░████████░░██████ ░░██████ ░░░░░░░░░ ░░░░░░ ░░░░░░░░ ░░░░░░ ░░░░░░

Envío 2054

Problema 0xcf - Mirando al horizonte

  • Autor: S8Vega
  • Fecha: 2020-11-20 04:50:52 UTC (Hace más de 3 años)
Caso # Resultado Tiempo Memoria
#1
Incorrecto
                      main.cpp:29:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
0.006 s 1 KBi
#2
Incorrecto
                      main.cpp:29:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
0.007 s 1 KBi
#3
Incorrecto
                      main.cpp:29:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
0.006 s 1 KBi
#4
Incorrecto
                      main.cpp:29:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
0.006 s 1 KBi
#5
Incorrecto
                      main.cpp:29:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
0.006 s 1 KBi
#6
Incorrecto
                      main.cpp:29:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
0.157 s 6 KBi
#7
Incorrecto
                      main.cpp:29:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
0.149 s 6 KBi
#8
Incorrecto
                      main.cpp:29:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
0.204 s 6 KBi
#9
Incorrecto
                      main.cpp:29:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
0.187 s 6 KBi
#10
Incorrecto
                      main.cpp:29:9: warning: 'dbg' macro redefined [-Wmacro-redefined]
#define dbg(...) 18
        ^
main.cpp:10:9: note: previous definition is here
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
        ^
1 warning generated.

                    
0.176 s 8 KBi
Puntos totales: 0 / 100

Código

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define forn(i, a, b) for (int i = a; i < b; ++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}

const int N = 5 * 1e5 + 10;
int n, a[N];

int main() {
#ifdef LOCAL
  freopen("a.txt", "r", stdin);
// freopen("main.txt", "w", stdout);
#else
  ios::sync_with_stdio(0);
  cin.tie(0);
#define endl '\n'
#define dbg(...) 18
#endif
  int t;
  cin >> t;
  for (int cs = 1; cs <= t; cs++) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    stack<int> pila;
    vector<int> ans(n);
    cout << "Case #" << cs << ": ";
    for (int i = n - 1; i >= 0; i--) {
      while (SZ(pila) && a[i] >= pila.top()) pila.pop();
      if (!SZ(pila))
        ans[i] = -1;
      else
        ans[i] = pila.top();
      pila.push(a[i]);
    }
    for (int x : ans) cout << ' ' << x;
    cout << endl;
  }
  return 0;
}