Submission #42999

#TimeUsernameProblemLanguageResultExecution timeMemory
42999PowerOfNinjaGoEditor (BOI15_edi)C++14
0 / 100
2 ms812 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 = 1e3+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]]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...