Submission #43005

# Submission time Handle Problem Language Result Execution time Memory
43005 2018-03-07T18:58:46 Z PowerOfNinjaGo Editor (BOI15_edi) C++14
0 / 100
1258 ms 196984 KB
//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[fnd-1][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]]);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 576 KB Output is correct
2 Incorrect 98 ms 98424 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1258 ms 196912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 726 ms 196984 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 576 KB Output is correct
2 Incorrect 98 ms 98424 KB Output isn't correct
3 Halted 0 ms 0 KB -