Submission #1127263

#TimeUsernameProblemLanguageResultExecution timeMemory
1127263KerimEditor (BOI15_edi)C++20
35 / 100
3070 ms8320 KiB
// O(n^2) #include <cstdio> #include <vector> using namespace std; 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 dezaktywuj(int x) { int i = 0; while (1){ if (i) oper[x].aktyw = true; else oper[x].aktyw = false; if (oper[x].poz > 0) x = oper[x].wsk; else break; i ^= 1; } } void aktywuj(int x) { oper[x].aktyw = true; if (oper[x].poz > 0) {//undo int i = x - 1; while (oper[i].poz >= oper[x].poz || !oper[i].aktyw) --i; oper[x].wsk = i; dezaktywuj(i); } } int wynik() { for (int i = oper.size() - 1; i >= 0; --i) if (oper[i].poz == 0 && oper[i].aktyw) return oper[i].wsk; return 0; } int n; int main() { // freopen("file.in", "r", stdin); scanf("%d", &n); for (int i = 0; i < n; ++i) { int edy; scanf("%d", &edy); oper.push_back(op(edy)); aktywuj(i); printf("%d\n", wynik()); } }

Compilation message (stderr)

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