Submission #501665

#TimeUsernameProblemLanguageResultExecution timeMemory
501665qwerasdfzxclMinerals (JOI19_minerals)C++14
75 / 100
22 ms2172 KiB
#include "minerals.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; void Solve(int N) { vector<int> A, B, ans(N); int cur = 0; for (int i=1;i<=N*2;i++){ int tmp = Query(i); if (tmp==cur) A.push_back(i); else B.push_back(i); cur = tmp; } for (int i=0;i<N;i++) if (!(i&1)){ cur = Query(B[i]); } //printf("YES\n"); for (int j=0;j<16;j++){ for (int i=0;i<N;i++){ if ((ans[i]|(1<<j)) >= N) continue; int tmp = Query(A[i]); if (tmp==cur) ans[i] |= 1<<j; cur = tmp; } if (j==15) break; for (int i=0;i<N;i++) if (((i>>j)&1) ^ ((i>>(j+1))&1)){ cur = Query(B[i]); } } //for (int i=0;i<N;i++) printf("%d ", ans[i]); for (int i=0;i<N;i++) Answer(A[i], B[ans[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...