답안 #43001

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
43001 2018-03-07T18:28:35 Z PowerOfNinjaGo Editor (BOI15_edi) C++14
0 / 100
133 ms 98404 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 tmp[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)
        {
            if(i>= 3)
            {
                for(int j = 0; j<= n; j++) tmp[j] = keep[i-2][j];
            }
            num[i] = x;
            tmp[0] = i;
            for(int j = 0; j<= n; j++) cur[j] = keep[i][j] = tmp[j];
        }
        else
        {
            x *= -1;
            int fnd = 0;
            for(int j = x-1; j>= 0; j--)
            {
                if(cur[j])
                {
                    fnd = cur[j]; break;
                }
            }
            //printf("fnd is %d\n", fnd);
            memset(tmp, 0, sizeof tmp);
            if(fnd>= 2) for(int j = 0; j<= n; j++) tmp[j] = keep[fnd-1][j];
            tmp[x] = i;
            for(int j = 0; j<= n; j++) cur[j] = keep[i][j] = tmp[j];
        }
        //printf("i = %d: ", i);
        //for(int i = 0; i<= n; i++) printf("%d ", cur[i]);
        //printf("\n");
        printf("%d\n", num[cur[0]]);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 133 ms 98404 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 98404 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 98404 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 133 ms 98404 KB Output isn't correct
3 Halted 0 ms 0 KB -