제출 #1127322

#제출 시각아이디문제언어결과실행 시간메모리
1127322KerimEditor (BOI15_edi)C++20
0 / 100
3094 ms9860 KiB
#include "bits/stdc++.h" using namespace std; struct edi{ int val; int lvl; int par; bool active; edi(int _val, int _lvl){ par = -1; 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(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(x, 0)); else{ v.push_back(edi(-1, -x)); //need to be optimized for (int j = i; j >= 0; j--){ if (v[j].active and v[j].lvl < v.back().lvl){ v[i].par = j; break; } } } //need to be optimized int cur = i; while (~cur){ v[cur].active ^= 1; cur = v[cur].par; } //need to be optimized int ans; for (int j = i; j >= 0; j--) if (v[j].active and v[j].lvl < 1){ ans = i; break; } printf("%d\n", v[ans].val); } }

컴파일 시 표준 에러 (stderr) 메시지

edi.cpp: In function 'int main()':
edi.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
edi.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         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...