제출 #1127286

#제출 시각아이디문제언어결과실행 시간메모리
1127286KerimEditor (BOI15_edi)C++20
35 / 100
3094 ms14472 KiB
#include "bits/stdc++.h" using namespace std; set<pair<int,int> > s; struct op { int poz; int wsk; bool aktyw; op(int edy) { if (edy < 0) poz = -edy; else wsk = edy, poz = 0; aktyw = false; } }; vector<op> oper; void add(int x){ // cout<<"add "<<x<<" "<<oper[x].poz<<endl; s.insert({x, oper[x].poz}); oper[x].aktyw = true; } void rem(int x){ s.erase({x, oper[x].poz}); oper[x].aktyw = false; } int get(int val){ auto it = s.end(); while (it != s.begin()){ it--; if (it->second < val) return it->first; } return -1; } void dezaktywuj(int x) { int i = 0; while (1){ if (i) add(x); else rem(x); if (oper[x].poz > 0) x = oper[x].wsk; else break; i ^= 1; } } void aktywuj(int x) { add(x); if (oper[x].poz > 0) { int i = get(oper[x].poz); oper[x].wsk = i; dezaktywuj(i); } } int n; int main() { // freopen("file.in", "r", stdin); scanf("%d", &n); s.insert({-1, 0}); for (int i = 0; i < n; ++i) { int edy; scanf("%d", &edy); oper.push_back(op(edy)); aktywuj(i); int val = get(1); if (val < 0) val = 0; else val = oper[val].wsk; printf("%d\n", val); } }

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

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