#include "minerals.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 1e5;
int mk[N];
int la = 0;
bool Ask(int u){
mk[u] ^= 1;
int res = Query(u);
bool ch = la != res;
la = res;
return ch;
}
void solve(vector<int> A, vector<int> B){
assert(A.size() == B.size());
int n = A.size();
if(n == 1){
Answer(A[0], B[0]);
return ;
}
int st = mk[A[0]];
int sz = 0;
if(st == 0){
for(int i = 0; i < n / 2; i++) Ask(A[i]);
sz = n / 2;
} else {
for(int i = 0; i < n / 2; i++) Ask(A[n - 1 - i]);
sz = (n + 1) / 2;
}
vector<int> A2[2], B2[2];
for(int i = 0; i < sz; i++) A2[0].pb(A[i]);
for(int i = sz; i < n; i++) A2[1].pb(A[i]);
for(auto x : B){
bool fl = Ask(x);
B2[fl ? 1 : 0].pb(x);
}
solve(A2[0], B2[0]);
solve(A2[1], B2[1]);
}
void Solve(int n) {
vector<int> A, B;
for(int i = 1; i <= n + n; i++)
if(Ask(i))
A.pb(i);
else
B.pb(i);
solve(A, B);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
328 KB |
Output is correct |
2 |
Correct |
3 ms |
328 KB |
Output is correct |
3 |
Correct |
5 ms |
584 KB |
Output is correct |
4 |
Correct |
13 ms |
840 KB |
Output is correct |
5 |
Correct |
19 ms |
1352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
328 KB |
Output is correct |
7 |
Correct |
5 ms |
584 KB |
Output is correct |
8 |
Correct |
13 ms |
840 KB |
Output is correct |
9 |
Correct |
19 ms |
1352 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
12 ms |
1096 KB |
Output is correct |
12 |
Correct |
18 ms |
1480 KB |
Output is correct |
13 |
Correct |
15 ms |
1480 KB |
Output is correct |
14 |
Correct |
16 ms |
1396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
328 KB |
Output is correct |
7 |
Correct |
5 ms |
584 KB |
Output is correct |
8 |
Correct |
13 ms |
840 KB |
Output is correct |
9 |
Correct |
19 ms |
1352 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
12 ms |
1096 KB |
Output is correct |
12 |
Correct |
18 ms |
1480 KB |
Output is correct |
13 |
Correct |
15 ms |
1480 KB |
Output is correct |
14 |
Correct |
16 ms |
1396 KB |
Output is correct |
15 |
Correct |
50 ms |
3408 KB |
Output is correct |
16 |
Correct |
56 ms |
3496 KB |
Output is correct |
17 |
Correct |
46 ms |
3336 KB |
Output is correct |
18 |
Correct |
47 ms |
3228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
328 KB |
Output is correct |
7 |
Correct |
5 ms |
584 KB |
Output is correct |
8 |
Correct |
13 ms |
840 KB |
Output is correct |
9 |
Correct |
19 ms |
1352 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
12 ms |
1096 KB |
Output is correct |
12 |
Correct |
18 ms |
1480 KB |
Output is correct |
13 |
Correct |
15 ms |
1480 KB |
Output is correct |
14 |
Correct |
16 ms |
1396 KB |
Output is correct |
15 |
Correct |
50 ms |
3408 KB |
Output is correct |
16 |
Correct |
56 ms |
3496 KB |
Output is correct |
17 |
Correct |
46 ms |
3336 KB |
Output is correct |
18 |
Correct |
47 ms |
3228 KB |
Output is correct |
19 |
Correct |
52 ms |
3584 KB |
Output is correct |
20 |
Correct |
53 ms |
3576 KB |
Output is correct |
21 |
Correct |
43 ms |
3388 KB |
Output is correct |
22 |
Correct |
44 ms |
3240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
328 KB |
Output is correct |
7 |
Correct |
5 ms |
584 KB |
Output is correct |
8 |
Correct |
13 ms |
840 KB |
Output is correct |
9 |
Correct |
19 ms |
1352 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
12 ms |
1096 KB |
Output is correct |
12 |
Correct |
18 ms |
1480 KB |
Output is correct |
13 |
Correct |
15 ms |
1480 KB |
Output is correct |
14 |
Correct |
16 ms |
1396 KB |
Output is correct |
15 |
Correct |
50 ms |
3408 KB |
Output is correct |
16 |
Correct |
56 ms |
3496 KB |
Output is correct |
17 |
Correct |
46 ms |
3336 KB |
Output is correct |
18 |
Correct |
47 ms |
3228 KB |
Output is correct |
19 |
Correct |
52 ms |
3584 KB |
Output is correct |
20 |
Correct |
53 ms |
3576 KB |
Output is correct |
21 |
Correct |
43 ms |
3388 KB |
Output is correct |
22 |
Correct |
44 ms |
3240 KB |
Output is correct |
23 |
Correct |
52 ms |
3544 KB |
Output is correct |
24 |
Correct |
59 ms |
3580 KB |
Output is correct |
25 |
Correct |
46 ms |
3556 KB |
Output is correct |
26 |
Correct |
50 ms |
3296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
328 KB |
Output is correct |
7 |
Correct |
5 ms |
584 KB |
Output is correct |
8 |
Correct |
13 ms |
840 KB |
Output is correct |
9 |
Correct |
19 ms |
1352 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
12 ms |
1096 KB |
Output is correct |
12 |
Correct |
18 ms |
1480 KB |
Output is correct |
13 |
Correct |
15 ms |
1480 KB |
Output is correct |
14 |
Correct |
16 ms |
1396 KB |
Output is correct |
15 |
Correct |
50 ms |
3408 KB |
Output is correct |
16 |
Correct |
56 ms |
3496 KB |
Output is correct |
17 |
Correct |
46 ms |
3336 KB |
Output is correct |
18 |
Correct |
47 ms |
3228 KB |
Output is correct |
19 |
Correct |
52 ms |
3584 KB |
Output is correct |
20 |
Correct |
53 ms |
3576 KB |
Output is correct |
21 |
Correct |
43 ms |
3388 KB |
Output is correct |
22 |
Correct |
44 ms |
3240 KB |
Output is correct |
23 |
Correct |
52 ms |
3544 KB |
Output is correct |
24 |
Correct |
59 ms |
3580 KB |
Output is correct |
25 |
Correct |
46 ms |
3556 KB |
Output is correct |
26 |
Correct |
50 ms |
3296 KB |
Output is correct |
27 |
Incorrect |
53 ms |
3728 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
328 KB |
Output is correct |
7 |
Correct |
5 ms |
584 KB |
Output is correct |
8 |
Correct |
13 ms |
840 KB |
Output is correct |
9 |
Correct |
19 ms |
1352 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
12 ms |
1096 KB |
Output is correct |
12 |
Correct |
18 ms |
1480 KB |
Output is correct |
13 |
Correct |
15 ms |
1480 KB |
Output is correct |
14 |
Correct |
16 ms |
1396 KB |
Output is correct |
15 |
Correct |
50 ms |
3408 KB |
Output is correct |
16 |
Correct |
56 ms |
3496 KB |
Output is correct |
17 |
Correct |
46 ms |
3336 KB |
Output is correct |
18 |
Correct |
47 ms |
3228 KB |
Output is correct |
19 |
Correct |
52 ms |
3584 KB |
Output is correct |
20 |
Correct |
53 ms |
3576 KB |
Output is correct |
21 |
Correct |
43 ms |
3388 KB |
Output is correct |
22 |
Correct |
44 ms |
3240 KB |
Output is correct |
23 |
Correct |
52 ms |
3544 KB |
Output is correct |
24 |
Correct |
59 ms |
3580 KB |
Output is correct |
25 |
Correct |
46 ms |
3556 KB |
Output is correct |
26 |
Correct |
50 ms |
3296 KB |
Output is correct |
27 |
Incorrect |
53 ms |
3728 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
2 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
328 KB |
Output is correct |
7 |
Correct |
5 ms |
584 KB |
Output is correct |
8 |
Correct |
13 ms |
840 KB |
Output is correct |
9 |
Correct |
19 ms |
1352 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
12 ms |
1096 KB |
Output is correct |
12 |
Correct |
18 ms |
1480 KB |
Output is correct |
13 |
Correct |
15 ms |
1480 KB |
Output is correct |
14 |
Correct |
16 ms |
1396 KB |
Output is correct |
15 |
Correct |
50 ms |
3408 KB |
Output is correct |
16 |
Correct |
56 ms |
3496 KB |
Output is correct |
17 |
Correct |
46 ms |
3336 KB |
Output is correct |
18 |
Correct |
47 ms |
3228 KB |
Output is correct |
19 |
Correct |
52 ms |
3584 KB |
Output is correct |
20 |
Correct |
53 ms |
3576 KB |
Output is correct |
21 |
Correct |
43 ms |
3388 KB |
Output is correct |
22 |
Correct |
44 ms |
3240 KB |
Output is correct |
23 |
Correct |
52 ms |
3544 KB |
Output is correct |
24 |
Correct |
59 ms |
3580 KB |
Output is correct |
25 |
Correct |
46 ms |
3556 KB |
Output is correct |
26 |
Correct |
50 ms |
3296 KB |
Output is correct |
27 |
Incorrect |
53 ms |
3728 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |