Submission #502640

#TimeUsernameProblemLanguageResultExecution timeMemory
502640sidonMinerals (JOI19_minerals)C++17
40 / 100
17 ms2116 KiB
#include "minerals.h" #include <bits/stdc++.h> using namespace std; const int LIM = 43e3; int A[LIM/2], L, R = -1; void extend(int lv, int rv) { while(lv < L) Query(A[--L]); while(rv > R) Query(A[++R]); while(lv > L) Query(A[L++]); while(rv < R) Query(A[R--]); } 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...