제출 #43002

#제출 시각아이디문제언어결과실행 시간메모리
43002PowerOfNinjaGoEditor (BOI15_edi)C++14
0 / 100
1288 ms197348 KiB
//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]]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...