Submission #502644

#TimeUsernameProblemLanguageResultExecution timeMemory
502644sidonMinerals (JOI19_minerals)C++17
40 / 100
23 ms2480 KiB
#include "minerals.h" #include <bits/stdc++.h> using namespace std; const int LIM = 43e3; int A[LIM], L, R = -1; void extend(int lv, int rv) { for(int _ : {1, 0}){ for(int i = L; i <= R; ++i) if(!(lv <= i && i <= rv)) Query(A[i]); if(_) swap(L, lv); if(_) swap(R, rv); } } void dfs(int l, int r, vector<int> b) { if(l == r) return; if(l == r - 1) return Answer(A[l], b[0]); int m = (l + r) / 2; extend(l, m-1); vector<int> bL, bR; for(int &i : b) { if((int)size(bL) == m - l) bR.push_back(i); else if((int)size(bR) == r - m) bL.push_back(i); else (Query(i) == Query(i) ? bL : bR).push_back(i); } dfs(l, m, bL); dfs(m, r, bR); } void Solve(int N) { vector<int> b; for(int i = 1; i <= N * 2; ++i) { if(R == N - 1 || Query(i) < R + 2) { b.push_back(i); Query(i); } else A[++R] = i; } dfs(0, N, b); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...