Submission #1111154

#TimeUsernameProblemLanguageResultExecution timeMemory
1111154Ghulam_JunaidEditor (BOI15_edi)C++17
15 / 100
480 ms6416 KiB
#include <bits/stdc++.h> using namespace std; const int N = 3e5 + 10; int n, a[N], p[N]; bool active[N]; int find(int x, bool del){ if (!active[x]) return p[x] = find(p[x], del); else{ if (del){ active[x] = 0; return find(x, 0); } return x; } } int main(){ cin >> n; for (int i = 1; i <= n; i ++) cin >> a[i]; active[0] = 1; int last = 0; for (int i = 1; i <= n; i ++){ if (a[i] > 0){ active[i] = 1; p[i] = last; last = i; cout << a[i] << endl; } else{ active[i] = 1; cout << a[find(last, 1)] << endl; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...