//Power Of Ninja Go
#include <bits/stdc++.h>
//#ifdef atom #else #endif
using namespace std;
typedef long long ll; typedef pair<int, int> ii;
#define X first
#define Y second
#define vi vector<int>
#define vii vector< ii >
#define pb push_back
const int maxn = 5e3+5;
int par[maxn];
int cur[maxn];
int keep[maxn][maxn];
int num[maxn];
int main()
{
//#ifndef atom freopen(".in", "r", stdin); freopen(".out", "w", stdout); #endif
int n; cin >> n;
for(int i = 1; i<= n; i++)
{
int x; cin >> x;
if(x> 0)
{
num[i] = x;
int foo = par[i-1];
for(int j = 0; j<= n; j++) keep[i][j] = keep[foo][j];
keep[i][0] = i;
par[i] = i-1;
}
else
{
x = -x;
int fnd = 0;
for(int j = x-1; j>= 0; j--)
{
if(keep[i-1][j])
{
fnd = keep[i-1][j]; break;
}
}
//printf("fnd is %d\n", fnd);
for(int j = 0; j<= n; j++) keep[i][j] = keep[par[fnd]][j];
keep[i][x] = i;
par[i] = fnd;
}
//printf("%d: ", i);
//for(int j = 0; j<= n; j++) printf("%d ", keep[i][j]);
//printf("\n");
printf("%d\n", num[keep[i][0]]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1288 ms |
196936 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
710 ms |
197348 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |