#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, cur, ans[100100], chk[100100];
void dnc0(vector<int> a);
void dnc1(vector<int> L, vector<int> R, int onL, int onR);
int myquery(int x, int typ = -1){
if (typ==chk[x]) return cur;
chk[x] ^= 1;
cur = Query(x);
return cur;
}
void dnc0(vector<int> a){
int c = a.size() / 2;
if (c==0) return;
if (c==1){
ans[a[0]] = a[1];
ans[a[1]] = a[0];
return;
}
vector<int> L, R;
for (auto &x:a){
int prv = cur;
int now = myquery(x);
if (now==prv){
R.push_back(x);
}
else{
L.push_back(x);
}
}
dnc1(L, R, 1, 1);
}
void dnc1(vector<int> L, vector<int> R, int onL, int onR){
// printf("dnc1: ");
// for (auto &x:L) printf("%d ", x);
// printf("\n");
// for (auto &x:R) printf("%d ", x);
// printf("\n");
int c = L.size();
if (c==0) return;
if (c==1){
ans[L[0]] = R[0];
ans[R[0]] = L[0];
return;
}
vector<int> L1, R1, L2, R2;
for (int i=0;i<c/2;i++) {L1.push_back(L[i]); myquery(L[i], !onL);}
for (int i=c/2;i<c;i++) L2.push_back(L[i]);
for (auto &x:R){
if (x==R.back()){
if (L1.size()!=R1.size()) R1.push_back(x);
else R2.push_back(x);
continue;
}
int prv = cur;
int delta = myquery(x, !onR) - prv;
if ((!onL) == (delta==0)) R1.push_back(x);
else R2.push_back(x);
}
dnc1(L1, R1, !onL, !onR);
dnc1(L2, R2, onL, !onR);
}
void Solve(int N) {
n = N, cur = 0;
vector<int> a;
for (int i=1;i<=n*2;i++) a.push_back(i);
dnc0(a);
for (int i=1;i<=n*2;i++) if (i < ans[i]) Answer(i, ans[i]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
2 ms |
464 KB |
Output is correct |
3 |
Correct |
4 ms |
720 KB |
Output is correct |
4 |
Correct |
8 ms |
1104 KB |
Output is correct |
5 |
Correct |
14 ms |
1744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
464 KB |
Output is correct |
7 |
Correct |
4 ms |
720 KB |
Output is correct |
8 |
Correct |
8 ms |
1104 KB |
Output is correct |
9 |
Correct |
14 ms |
1744 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
11 ms |
1344 KB |
Output is correct |
12 |
Correct |
15 ms |
1788 KB |
Output is correct |
13 |
Correct |
12 ms |
1896 KB |
Output is correct |
14 |
Correct |
15 ms |
1744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
464 KB |
Output is correct |
7 |
Correct |
4 ms |
720 KB |
Output is correct |
8 |
Correct |
8 ms |
1104 KB |
Output is correct |
9 |
Correct |
14 ms |
1744 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
11 ms |
1344 KB |
Output is correct |
12 |
Correct |
15 ms |
1788 KB |
Output is correct |
13 |
Correct |
12 ms |
1896 KB |
Output is correct |
14 |
Correct |
15 ms |
1744 KB |
Output is correct |
15 |
Correct |
47 ms |
4076 KB |
Output is correct |
16 |
Correct |
42 ms |
4084 KB |
Output is correct |
17 |
Correct |
34 ms |
3968 KB |
Output is correct |
18 |
Correct |
35 ms |
3832 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
464 KB |
Output is correct |
7 |
Correct |
4 ms |
720 KB |
Output is correct |
8 |
Correct |
8 ms |
1104 KB |
Output is correct |
9 |
Correct |
14 ms |
1744 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
11 ms |
1344 KB |
Output is correct |
12 |
Correct |
15 ms |
1788 KB |
Output is correct |
13 |
Correct |
12 ms |
1896 KB |
Output is correct |
14 |
Correct |
15 ms |
1744 KB |
Output is correct |
15 |
Correct |
47 ms |
4076 KB |
Output is correct |
16 |
Correct |
42 ms |
4084 KB |
Output is correct |
17 |
Correct |
34 ms |
3968 KB |
Output is correct |
18 |
Correct |
35 ms |
3832 KB |
Output is correct |
19 |
Correct |
41 ms |
4160 KB |
Output is correct |
20 |
Correct |
44 ms |
4192 KB |
Output is correct |
21 |
Correct |
39 ms |
4224 KB |
Output is correct |
22 |
Correct |
34 ms |
3876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
464 KB |
Output is correct |
7 |
Correct |
4 ms |
720 KB |
Output is correct |
8 |
Correct |
8 ms |
1104 KB |
Output is correct |
9 |
Correct |
14 ms |
1744 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
11 ms |
1344 KB |
Output is correct |
12 |
Correct |
15 ms |
1788 KB |
Output is correct |
13 |
Correct |
12 ms |
1896 KB |
Output is correct |
14 |
Correct |
15 ms |
1744 KB |
Output is correct |
15 |
Correct |
47 ms |
4076 KB |
Output is correct |
16 |
Correct |
42 ms |
4084 KB |
Output is correct |
17 |
Correct |
34 ms |
3968 KB |
Output is correct |
18 |
Correct |
35 ms |
3832 KB |
Output is correct |
19 |
Correct |
41 ms |
4160 KB |
Output is correct |
20 |
Correct |
44 ms |
4192 KB |
Output is correct |
21 |
Correct |
39 ms |
4224 KB |
Output is correct |
22 |
Correct |
34 ms |
3876 KB |
Output is correct |
23 |
Correct |
43 ms |
4252 KB |
Output is correct |
24 |
Correct |
43 ms |
4212 KB |
Output is correct |
25 |
Correct |
34 ms |
4140 KB |
Output is correct |
26 |
Correct |
35 ms |
4180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
464 KB |
Output is correct |
7 |
Correct |
4 ms |
720 KB |
Output is correct |
8 |
Correct |
8 ms |
1104 KB |
Output is correct |
9 |
Correct |
14 ms |
1744 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
11 ms |
1344 KB |
Output is correct |
12 |
Correct |
15 ms |
1788 KB |
Output is correct |
13 |
Correct |
12 ms |
1896 KB |
Output is correct |
14 |
Correct |
15 ms |
1744 KB |
Output is correct |
15 |
Correct |
47 ms |
4076 KB |
Output is correct |
16 |
Correct |
42 ms |
4084 KB |
Output is correct |
17 |
Correct |
34 ms |
3968 KB |
Output is correct |
18 |
Correct |
35 ms |
3832 KB |
Output is correct |
19 |
Correct |
41 ms |
4160 KB |
Output is correct |
20 |
Correct |
44 ms |
4192 KB |
Output is correct |
21 |
Correct |
39 ms |
4224 KB |
Output is correct |
22 |
Correct |
34 ms |
3876 KB |
Output is correct |
23 |
Correct |
43 ms |
4252 KB |
Output is correct |
24 |
Correct |
43 ms |
4212 KB |
Output is correct |
25 |
Correct |
34 ms |
4140 KB |
Output is correct |
26 |
Correct |
35 ms |
4180 KB |
Output is correct |
27 |
Correct |
42 ms |
4352 KB |
Output is correct |
28 |
Correct |
49 ms |
4324 KB |
Output is correct |
29 |
Correct |
38 ms |
4276 KB |
Output is correct |
30 |
Correct |
46 ms |
4060 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
464 KB |
Output is correct |
7 |
Correct |
4 ms |
720 KB |
Output is correct |
8 |
Correct |
8 ms |
1104 KB |
Output is correct |
9 |
Correct |
14 ms |
1744 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
11 ms |
1344 KB |
Output is correct |
12 |
Correct |
15 ms |
1788 KB |
Output is correct |
13 |
Correct |
12 ms |
1896 KB |
Output is correct |
14 |
Correct |
15 ms |
1744 KB |
Output is correct |
15 |
Correct |
47 ms |
4076 KB |
Output is correct |
16 |
Correct |
42 ms |
4084 KB |
Output is correct |
17 |
Correct |
34 ms |
3968 KB |
Output is correct |
18 |
Correct |
35 ms |
3832 KB |
Output is correct |
19 |
Correct |
41 ms |
4160 KB |
Output is correct |
20 |
Correct |
44 ms |
4192 KB |
Output is correct |
21 |
Correct |
39 ms |
4224 KB |
Output is correct |
22 |
Correct |
34 ms |
3876 KB |
Output is correct |
23 |
Correct |
43 ms |
4252 KB |
Output is correct |
24 |
Correct |
43 ms |
4212 KB |
Output is correct |
25 |
Correct |
34 ms |
4140 KB |
Output is correct |
26 |
Correct |
35 ms |
4180 KB |
Output is correct |
27 |
Correct |
42 ms |
4352 KB |
Output is correct |
28 |
Correct |
49 ms |
4324 KB |
Output is correct |
29 |
Correct |
38 ms |
4276 KB |
Output is correct |
30 |
Correct |
46 ms |
4060 KB |
Output is correct |
31 |
Incorrect |
41 ms |
4460 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
336 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
2 ms |
464 KB |
Output is correct |
7 |
Correct |
4 ms |
720 KB |
Output is correct |
8 |
Correct |
8 ms |
1104 KB |
Output is correct |
9 |
Correct |
14 ms |
1744 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
11 ms |
1344 KB |
Output is correct |
12 |
Correct |
15 ms |
1788 KB |
Output is correct |
13 |
Correct |
12 ms |
1896 KB |
Output is correct |
14 |
Correct |
15 ms |
1744 KB |
Output is correct |
15 |
Correct |
47 ms |
4076 KB |
Output is correct |
16 |
Correct |
42 ms |
4084 KB |
Output is correct |
17 |
Correct |
34 ms |
3968 KB |
Output is correct |
18 |
Correct |
35 ms |
3832 KB |
Output is correct |
19 |
Correct |
41 ms |
4160 KB |
Output is correct |
20 |
Correct |
44 ms |
4192 KB |
Output is correct |
21 |
Correct |
39 ms |
4224 KB |
Output is correct |
22 |
Correct |
34 ms |
3876 KB |
Output is correct |
23 |
Correct |
43 ms |
4252 KB |
Output is correct |
24 |
Correct |
43 ms |
4212 KB |
Output is correct |
25 |
Correct |
34 ms |
4140 KB |
Output is correct |
26 |
Correct |
35 ms |
4180 KB |
Output is correct |
27 |
Correct |
42 ms |
4352 KB |
Output is correct |
28 |
Correct |
49 ms |
4324 KB |
Output is correct |
29 |
Correct |
38 ms |
4276 KB |
Output is correct |
30 |
Correct |
46 ms |
4060 KB |
Output is correct |
31 |
Incorrect |
41 ms |
4460 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |