Submission #1127321

#TimeUsernameProblemLanguageResultExecution timeMemory
1127321KerimEditor (BOI15_edi)C++20
35 / 100
3089 ms12416 KiB
#include "bits/stdc++.h" using namespace std; struct edi{ int tp; int val; int lvl; int par; bool active; edi(int _tp, int _val, int _lvl){ par = -1; tp = _tp; val = _val; lvl = _lvl; active = 0; } }; int main(){ // freopen("file.in", "r", stdin); int n; scanf("%d", &n); vector<edi> v; v.push_back(edi(1, 0, 0)); v[0].active = 1; for (int i = 1; i <= n; i++){ int x; scanf("%d", &x); if (x > 0) v.push_back(edi(1, x, 0)); else{ v.push_back(edi(2, -1, -x)); for (int j = i-1; j >= 0; j--){ if (v[j].active and v[j].lvl < v.back().lvl){ v[i].par = j; break; } } } int cur = i; while (~cur){ v[cur].active ^= 1; cur = v[cur].par; } int ans = i; while (!v[ans].active or v[ans].tp == 2) ans -= 1; printf("%d\n", v[ans].val); } }

Compilation message (stderr)

edi.cpp: In function 'int main()':
edi.cpp:23:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
edi.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf("%d", &x);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...