This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |