Submission #836155

#TimeUsernameProblemLanguageResultExecution timeMemory
836155unnickMinerals (JOI19_minerals)C++14
40 / 100
14 ms1744 KiB
#include "minerals.h" #include <vector> using namespace std; void Solve(int N) { vector<int> fst; vector<int> snd; int prev = 0; for (int i = 1; i <= N*2; i++) { int tmp = Query(i); if (tmp > prev) fst.push_back(i); prev = tmp; } for (int i = 1; i <= N*2; i++) { int tmp = Query(i); if (tmp < prev) snd.push_back(i); prev = tmp; } int baseline = 0; for (int i = 0; i < N; i++) { if (i&1) baseline = Query(fst[i]); } vector<int> ids(N, 0); for (int pd = 1; pd < N; pd <<= 1) { if (pd > 1) { for (int i = 0; i < N; i++) { if ((i&pd) ^ ((i<<1)&pd)) baseline = Query(fst[i]); } } for (int i = 0; i < N; i++) { int tmp = Query(snd[i]); int bit = (tmp == baseline); baseline = tmp; ids[i] += bit * pd; } } for (int i = 0; i < N; i++) { Answer(fst[ids[i]], snd[i]); } }
#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...