#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
void Solve(int n) {
vector <int> pos, ok(2 * n);
int ans = 0, i;
for(i = 0; i < 2 * n; i++) {
int cur = Query(i + 1);
if(cur == ans) {
pos.push_back(i);
ok[i] = 1;
}
ans = cur;
}
for(i = 0; i < 2 * n; i++) {
Query(i + 1);
}
vector <int> sol(2 * n), in(2 * n);
ans = 0;
for(int bit = 15; bit >= 0; bit--) {
if((1 << bit) >= n) continue;
for(i = 0; i < n; i++) {
if(i & (1 << bit)) {
if(in[i]) continue;
ans = Query(pos[i] + 1);
in[i] = 1;
}
}
for(i = 0; i < 2 * n; i++) {
if(ok[i] == 0) {
if(Query(i + 1) == ans) {
sol[i] ^= (1 << bit);
}
Query(i + 1);
}
}
if(bit == 0) break;
for(i = 0; i < n; i++) {
if(i & (1 << bit)) {
if(i & (1 << (bit - 1))) continue;
Query(pos[i] + 1);
in[i] = 0;
}
}
}
for(i = 0; i < 2 * n; i++) {
if(ok[i] == 0) {
//cerr << i + 1 << " " << sol[i] + 1 << "\n";
Answer(i + 1, pos[sol[i]] + 1);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
5 ms |
632 KB |
Output is correct |
4 |
Correct |
8 ms |
760 KB |
Output is correct |
5 |
Correct |
19 ms |
1144 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
8 ms |
760 KB |
Output is correct |
9 |
Correct |
19 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
12 ms |
888 KB |
Output is correct |
12 |
Correct |
17 ms |
1268 KB |
Output is correct |
13 |
Correct |
14 ms |
1208 KB |
Output is correct |
14 |
Correct |
14 ms |
1144 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
8 ms |
760 KB |
Output is correct |
9 |
Correct |
19 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
12 ms |
888 KB |
Output is correct |
12 |
Correct |
17 ms |
1268 KB |
Output is correct |
13 |
Correct |
14 ms |
1208 KB |
Output is correct |
14 |
Correct |
14 ms |
1144 KB |
Output is correct |
15 |
Incorrect |
31 ms |
2412 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
8 ms |
760 KB |
Output is correct |
9 |
Correct |
19 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
12 ms |
888 KB |
Output is correct |
12 |
Correct |
17 ms |
1268 KB |
Output is correct |
13 |
Correct |
14 ms |
1208 KB |
Output is correct |
14 |
Correct |
14 ms |
1144 KB |
Output is correct |
15 |
Incorrect |
31 ms |
2412 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
8 ms |
760 KB |
Output is correct |
9 |
Correct |
19 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
12 ms |
888 KB |
Output is correct |
12 |
Correct |
17 ms |
1268 KB |
Output is correct |
13 |
Correct |
14 ms |
1208 KB |
Output is correct |
14 |
Correct |
14 ms |
1144 KB |
Output is correct |
15 |
Incorrect |
31 ms |
2412 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
8 ms |
760 KB |
Output is correct |
9 |
Correct |
19 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
12 ms |
888 KB |
Output is correct |
12 |
Correct |
17 ms |
1268 KB |
Output is correct |
13 |
Correct |
14 ms |
1208 KB |
Output is correct |
14 |
Correct |
14 ms |
1144 KB |
Output is correct |
15 |
Incorrect |
31 ms |
2412 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
8 ms |
760 KB |
Output is correct |
9 |
Correct |
19 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
12 ms |
888 KB |
Output is correct |
12 |
Correct |
17 ms |
1268 KB |
Output is correct |
13 |
Correct |
14 ms |
1208 KB |
Output is correct |
14 |
Correct |
14 ms |
1144 KB |
Output is correct |
15 |
Incorrect |
31 ms |
2412 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
504 KB |
Output is correct |
7 |
Correct |
5 ms |
632 KB |
Output is correct |
8 |
Correct |
8 ms |
760 KB |
Output is correct |
9 |
Correct |
19 ms |
1144 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
12 ms |
888 KB |
Output is correct |
12 |
Correct |
17 ms |
1268 KB |
Output is correct |
13 |
Correct |
14 ms |
1208 KB |
Output is correct |
14 |
Correct |
14 ms |
1144 KB |
Output is correct |
15 |
Incorrect |
31 ms |
2412 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |