#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int curr = 0;
bool change(int u){
int nxt = Query(u);
bool res = (nxt != curr);
curr = nxt;
return res;
}
void rec(vector<int> &A,vector<int> &B,bool rev){
int len = A.size();
if(len == 1){
Answer(A[0],B[0]);
return;
}
shuffle(A.begin(),A.end(),rng);
shuffle(B.begin(),B.end(),rng);
int mid = (rev?382:618)*len/1000;
if(mid == 0) mid++;
if(mid == len) mid--;
vector<int> nA[2],nB[2];
for(int i=0;i<len;i++){
if(i < mid){
change(A[i]);
nA[0].push_back(A[i]);
}else nA[1].push_back(A[i]);
}
for(int i=0;i<len;i++){
if(nB[0].size() == nA[0].size()) nB[1].push_back(B[i]);
else if(nB[1].size() == nA[1].size()) nB[0].push_back(B[i]);
else if(change(B[i])) nB[rev^1].push_back(B[i]);
else nB[rev].push_back(B[i]);
}
rec(nA[0],nB[0],rev^1);
rec(nA[1],nB[1],rev);
}
void Solve(int N){
vector<int> group[2];
for(int i=1;i<=2*N;i++) group[change(i)].push_back(i);
rec(group[0],group[1],1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 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 |
6 ms |
456 KB |
Output is correct |
4 |
Correct |
12 ms |
772 KB |
Output is correct |
5 |
Correct |
24 ms |
1216 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 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 |
6 ms |
456 KB |
Output is correct |
8 |
Correct |
12 ms |
772 KB |
Output is correct |
9 |
Correct |
24 ms |
1216 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
18 ms |
956 KB |
Output is correct |
12 |
Correct |
24 ms |
1224 KB |
Output is correct |
13 |
Correct |
23 ms |
1224 KB |
Output is correct |
14 |
Correct |
23 ms |
1204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 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 |
6 ms |
456 KB |
Output is correct |
8 |
Correct |
12 ms |
772 KB |
Output is correct |
9 |
Correct |
24 ms |
1216 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
18 ms |
956 KB |
Output is correct |
12 |
Correct |
24 ms |
1224 KB |
Output is correct |
13 |
Correct |
23 ms |
1224 KB |
Output is correct |
14 |
Correct |
23 ms |
1204 KB |
Output is correct |
15 |
Correct |
76 ms |
2740 KB |
Output is correct |
16 |
Correct |
74 ms |
2764 KB |
Output is correct |
17 |
Correct |
72 ms |
2856 KB |
Output is correct |
18 |
Correct |
72 ms |
2624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 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 |
6 ms |
456 KB |
Output is correct |
8 |
Correct |
12 ms |
772 KB |
Output is correct |
9 |
Correct |
24 ms |
1216 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
18 ms |
956 KB |
Output is correct |
12 |
Correct |
24 ms |
1224 KB |
Output is correct |
13 |
Correct |
23 ms |
1224 KB |
Output is correct |
14 |
Correct |
23 ms |
1204 KB |
Output is correct |
15 |
Correct |
76 ms |
2740 KB |
Output is correct |
16 |
Correct |
74 ms |
2764 KB |
Output is correct |
17 |
Correct |
72 ms |
2856 KB |
Output is correct |
18 |
Correct |
72 ms |
2624 KB |
Output is correct |
19 |
Correct |
69 ms |
2760 KB |
Output is correct |
20 |
Correct |
83 ms |
2804 KB |
Output is correct |
21 |
Correct |
70 ms |
2772 KB |
Output is correct |
22 |
Correct |
68 ms |
2628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 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 |
6 ms |
456 KB |
Output is correct |
8 |
Correct |
12 ms |
772 KB |
Output is correct |
9 |
Correct |
24 ms |
1216 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
18 ms |
956 KB |
Output is correct |
12 |
Correct |
24 ms |
1224 KB |
Output is correct |
13 |
Correct |
23 ms |
1224 KB |
Output is correct |
14 |
Correct |
23 ms |
1204 KB |
Output is correct |
15 |
Correct |
76 ms |
2740 KB |
Output is correct |
16 |
Correct |
74 ms |
2764 KB |
Output is correct |
17 |
Correct |
72 ms |
2856 KB |
Output is correct |
18 |
Correct |
72 ms |
2624 KB |
Output is correct |
19 |
Correct |
69 ms |
2760 KB |
Output is correct |
20 |
Correct |
83 ms |
2804 KB |
Output is correct |
21 |
Correct |
70 ms |
2772 KB |
Output is correct |
22 |
Correct |
68 ms |
2628 KB |
Output is correct |
23 |
Correct |
71 ms |
2780 KB |
Output is correct |
24 |
Correct |
71 ms |
2816 KB |
Output is correct |
25 |
Correct |
71 ms |
2816 KB |
Output is correct |
26 |
Correct |
70 ms |
2648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 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 |
6 ms |
456 KB |
Output is correct |
8 |
Correct |
12 ms |
772 KB |
Output is correct |
9 |
Correct |
24 ms |
1216 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
18 ms |
956 KB |
Output is correct |
12 |
Correct |
24 ms |
1224 KB |
Output is correct |
13 |
Correct |
23 ms |
1224 KB |
Output is correct |
14 |
Correct |
23 ms |
1204 KB |
Output is correct |
15 |
Correct |
76 ms |
2740 KB |
Output is correct |
16 |
Correct |
74 ms |
2764 KB |
Output is correct |
17 |
Correct |
72 ms |
2856 KB |
Output is correct |
18 |
Correct |
72 ms |
2624 KB |
Output is correct |
19 |
Correct |
69 ms |
2760 KB |
Output is correct |
20 |
Correct |
83 ms |
2804 KB |
Output is correct |
21 |
Correct |
70 ms |
2772 KB |
Output is correct |
22 |
Correct |
68 ms |
2628 KB |
Output is correct |
23 |
Correct |
71 ms |
2780 KB |
Output is correct |
24 |
Correct |
71 ms |
2816 KB |
Output is correct |
25 |
Correct |
71 ms |
2816 KB |
Output is correct |
26 |
Correct |
70 ms |
2648 KB |
Output is correct |
27 |
Correct |
80 ms |
2928 KB |
Output is correct |
28 |
Correct |
71 ms |
2912 KB |
Output is correct |
29 |
Correct |
71 ms |
2880 KB |
Output is correct |
30 |
Correct |
71 ms |
2752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 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 |
6 ms |
456 KB |
Output is correct |
8 |
Correct |
12 ms |
772 KB |
Output is correct |
9 |
Correct |
24 ms |
1216 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
18 ms |
956 KB |
Output is correct |
12 |
Correct |
24 ms |
1224 KB |
Output is correct |
13 |
Correct |
23 ms |
1224 KB |
Output is correct |
14 |
Correct |
23 ms |
1204 KB |
Output is correct |
15 |
Correct |
76 ms |
2740 KB |
Output is correct |
16 |
Correct |
74 ms |
2764 KB |
Output is correct |
17 |
Correct |
72 ms |
2856 KB |
Output is correct |
18 |
Correct |
72 ms |
2624 KB |
Output is correct |
19 |
Correct |
69 ms |
2760 KB |
Output is correct |
20 |
Correct |
83 ms |
2804 KB |
Output is correct |
21 |
Correct |
70 ms |
2772 KB |
Output is correct |
22 |
Correct |
68 ms |
2628 KB |
Output is correct |
23 |
Correct |
71 ms |
2780 KB |
Output is correct |
24 |
Correct |
71 ms |
2816 KB |
Output is correct |
25 |
Correct |
71 ms |
2816 KB |
Output is correct |
26 |
Correct |
70 ms |
2648 KB |
Output is correct |
27 |
Correct |
80 ms |
2928 KB |
Output is correct |
28 |
Correct |
71 ms |
2912 KB |
Output is correct |
29 |
Correct |
71 ms |
2880 KB |
Output is correct |
30 |
Correct |
71 ms |
2752 KB |
Output is correct |
31 |
Incorrect |
83 ms |
2880 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 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 |
6 ms |
456 KB |
Output is correct |
8 |
Correct |
12 ms |
772 KB |
Output is correct |
9 |
Correct |
24 ms |
1216 KB |
Output is correct |
10 |
Correct |
2 ms |
328 KB |
Output is correct |
11 |
Correct |
18 ms |
956 KB |
Output is correct |
12 |
Correct |
24 ms |
1224 KB |
Output is correct |
13 |
Correct |
23 ms |
1224 KB |
Output is correct |
14 |
Correct |
23 ms |
1204 KB |
Output is correct |
15 |
Correct |
76 ms |
2740 KB |
Output is correct |
16 |
Correct |
74 ms |
2764 KB |
Output is correct |
17 |
Correct |
72 ms |
2856 KB |
Output is correct |
18 |
Correct |
72 ms |
2624 KB |
Output is correct |
19 |
Correct |
69 ms |
2760 KB |
Output is correct |
20 |
Correct |
83 ms |
2804 KB |
Output is correct |
21 |
Correct |
70 ms |
2772 KB |
Output is correct |
22 |
Correct |
68 ms |
2628 KB |
Output is correct |
23 |
Correct |
71 ms |
2780 KB |
Output is correct |
24 |
Correct |
71 ms |
2816 KB |
Output is correct |
25 |
Correct |
71 ms |
2816 KB |
Output is correct |
26 |
Correct |
70 ms |
2648 KB |
Output is correct |
27 |
Correct |
80 ms |
2928 KB |
Output is correct |
28 |
Correct |
71 ms |
2912 KB |
Output is correct |
29 |
Correct |
71 ms |
2880 KB |
Output is correct |
30 |
Correct |
71 ms |
2752 KB |
Output is correct |
31 |
Incorrect |
83 ms |
2880 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |