Submission #105773

#TimeUsernameProblemLanguageResultExecution timeMemory
105773RezwanArefin01Jousting tournament (IOI12_tournament)C++17
100 / 100
213 ms12584 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef pair<int, int> ii; typedef tree< ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; const int M = 2e5 + 10; struct node { int sum, flag, l, d; node(int s=0, int f=0, int l=0, int d=0) : sum(s), flag(f), l(l), d(d) {} } t[M]; int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) { ordered_set st; for(int i = 0; i < N - 1; i++) { t[i] = node(K[i] > R, K[i] > R, i, 0); st.insert({i, i}); } t[N - 1] = node(0, 0, N - 1, 0); st.insert({N - 1, N - 1}); int idx = N; for(int i = 0; i < C; i++) { auto s = st.find_by_order(S[i]); auto e = st.find_by_order(E[i]); int lid = s -> second, rid = e -> second; ++e; while(s != e) { int id = s -> second; t[idx].sum += t[id].sum; if(t[id].d + 1 > t[idx].d) { t[idx].d = t[id].d + 1; t[idx].l = t[id].l; } auto it = s; s++; st.erase(it); } t[idx].flag = t[rid].flag; st.insert({t[idx].l, idx}); idx++; } int maxwin = 0, ans = 0; for(int i = 0; i < idx; i++) if(t[i].d >= maxwin){ if(t[i].sum == 0 || (t[i].sum == 1 && t[i].flag)) { if(t[i].d > maxwin) { maxwin = t[i].d; ans = t[i].l; } else { ans = min(ans, t[i].l); } } } return ans; }

Compilation message (stderr)

tournament.cpp: In function 'int GetBestPosition(int, int, int, int*, int*, int*)':
tournament.cpp:37:7: warning: unused variable 'lid' [-Wunused-variable]
   int lid = s -> second, rid = e -> second; 
       ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...