#include "minerals.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int n;
bool chk[100002];
int order[100002], ocnt;
int ans[100002];
bool in[100002];
int lastRet;
int query(int x){
in[x] = !in[x];
return Query(order[x]);
}
void solve(int l, int r, vector<int>& vec){
if(l==r){
ans[l] = vec[0];
return;
}
int m = int(double(l) * 0.32 + double(r) * 0.68);
if(m<l) m++;
if(m>r) m--;
int tmpCalc = 0;
bool st = 0;
for(int i=l; i<=m; i++) if(!in[i]) tmpCalc++;
for(int i=m+1; i<=r; i++) if(in[i]) tmpCalc++;
if(tmpCalc * 2 > r-l+1) st = 1;
for(int i=l; i<=m; i++){
if(in[i] == st) lastRet = query(i);
}
for(int i=m+1; i<=r; i++){
if(in[i] != st) lastRet = query(i);
}
vector<int> lVec, rVec;
for(auto x: vec){
if((int)lVec.size() == m-l+1){
rVec.push_back(x);
continue;
}
else if((int)rVec.size() == r-m){
lVec.push_back(x);
continue;
}
int tmp = query(x);
if((tmp == lastRet) ^ st) lVec.push_back(x);
else rVec.push_back(x);
lastRet = tmp;
}
solve(l, m, lVec);
solve(m+1, r, rVec);
}
void Solve(int N){
n = N;
for(int i=1; i<=n+n; i++){
int tmp = Query(i);
if(tmp != lastRet) order[++ocnt] = i, chk[i] = 1;
lastRet = tmp;
in[i] = 1;
}
for(int i=1; i<=n+n; i++) if(!chk[i]) order[++ocnt] = i;
vector<int> tVec;
for(int i=n+1; i<=n+n; i++) tVec.push_back(i);
solve(1, n, tVec);
for(int i=1; i<=n; i++) Answer(order[i], order[ans[i]]);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
2 ms |
328 KB |
Output is correct |
3 |
Correct |
3 ms |
584 KB |
Output is correct |
4 |
Correct |
5 ms |
712 KB |
Output is correct |
5 |
Correct |
11 ms |
1184 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
712 KB |
Output is correct |
9 |
Correct |
11 ms |
1184 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
9 ms |
904 KB |
Output is correct |
12 |
Correct |
11 ms |
1308 KB |
Output is correct |
13 |
Correct |
9 ms |
1252 KB |
Output is correct |
14 |
Correct |
8 ms |
1252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
712 KB |
Output is correct |
9 |
Correct |
11 ms |
1184 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
9 ms |
904 KB |
Output is correct |
12 |
Correct |
11 ms |
1308 KB |
Output is correct |
13 |
Correct |
9 ms |
1252 KB |
Output is correct |
14 |
Correct |
8 ms |
1252 KB |
Output is correct |
15 |
Correct |
31 ms |
2728 KB |
Output is correct |
16 |
Correct |
31 ms |
2876 KB |
Output is correct |
17 |
Correct |
22 ms |
2812 KB |
Output is correct |
18 |
Correct |
20 ms |
2608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
712 KB |
Output is correct |
9 |
Correct |
11 ms |
1184 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
9 ms |
904 KB |
Output is correct |
12 |
Correct |
11 ms |
1308 KB |
Output is correct |
13 |
Correct |
9 ms |
1252 KB |
Output is correct |
14 |
Correct |
8 ms |
1252 KB |
Output is correct |
15 |
Correct |
31 ms |
2728 KB |
Output is correct |
16 |
Correct |
31 ms |
2876 KB |
Output is correct |
17 |
Correct |
22 ms |
2812 KB |
Output is correct |
18 |
Correct |
20 ms |
2608 KB |
Output is correct |
19 |
Correct |
40 ms |
2848 KB |
Output is correct |
20 |
Correct |
31 ms |
2896 KB |
Output is correct |
21 |
Correct |
22 ms |
2860 KB |
Output is correct |
22 |
Correct |
26 ms |
2620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
712 KB |
Output is correct |
9 |
Correct |
11 ms |
1184 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
9 ms |
904 KB |
Output is correct |
12 |
Correct |
11 ms |
1308 KB |
Output is correct |
13 |
Correct |
9 ms |
1252 KB |
Output is correct |
14 |
Correct |
8 ms |
1252 KB |
Output is correct |
15 |
Correct |
31 ms |
2728 KB |
Output is correct |
16 |
Correct |
31 ms |
2876 KB |
Output is correct |
17 |
Correct |
22 ms |
2812 KB |
Output is correct |
18 |
Correct |
20 ms |
2608 KB |
Output is correct |
19 |
Correct |
40 ms |
2848 KB |
Output is correct |
20 |
Correct |
31 ms |
2896 KB |
Output is correct |
21 |
Correct |
22 ms |
2860 KB |
Output is correct |
22 |
Correct |
26 ms |
2620 KB |
Output is correct |
23 |
Correct |
38 ms |
2880 KB |
Output is correct |
24 |
Correct |
34 ms |
2876 KB |
Output is correct |
25 |
Correct |
23 ms |
2916 KB |
Output is correct |
26 |
Correct |
26 ms |
2684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
712 KB |
Output is correct |
9 |
Correct |
11 ms |
1184 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
9 ms |
904 KB |
Output is correct |
12 |
Correct |
11 ms |
1308 KB |
Output is correct |
13 |
Correct |
9 ms |
1252 KB |
Output is correct |
14 |
Correct |
8 ms |
1252 KB |
Output is correct |
15 |
Correct |
31 ms |
2728 KB |
Output is correct |
16 |
Correct |
31 ms |
2876 KB |
Output is correct |
17 |
Correct |
22 ms |
2812 KB |
Output is correct |
18 |
Correct |
20 ms |
2608 KB |
Output is correct |
19 |
Correct |
40 ms |
2848 KB |
Output is correct |
20 |
Correct |
31 ms |
2896 KB |
Output is correct |
21 |
Correct |
22 ms |
2860 KB |
Output is correct |
22 |
Correct |
26 ms |
2620 KB |
Output is correct |
23 |
Correct |
38 ms |
2880 KB |
Output is correct |
24 |
Correct |
34 ms |
2876 KB |
Output is correct |
25 |
Correct |
23 ms |
2916 KB |
Output is correct |
26 |
Correct |
26 ms |
2684 KB |
Output is correct |
27 |
Correct |
34 ms |
3064 KB |
Output is correct |
28 |
Correct |
33 ms |
2964 KB |
Output is correct |
29 |
Correct |
24 ms |
2992 KB |
Output is correct |
30 |
Correct |
22 ms |
2748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
712 KB |
Output is correct |
9 |
Correct |
11 ms |
1184 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
9 ms |
904 KB |
Output is correct |
12 |
Correct |
11 ms |
1308 KB |
Output is correct |
13 |
Correct |
9 ms |
1252 KB |
Output is correct |
14 |
Correct |
8 ms |
1252 KB |
Output is correct |
15 |
Correct |
31 ms |
2728 KB |
Output is correct |
16 |
Correct |
31 ms |
2876 KB |
Output is correct |
17 |
Correct |
22 ms |
2812 KB |
Output is correct |
18 |
Correct |
20 ms |
2608 KB |
Output is correct |
19 |
Correct |
40 ms |
2848 KB |
Output is correct |
20 |
Correct |
31 ms |
2896 KB |
Output is correct |
21 |
Correct |
22 ms |
2860 KB |
Output is correct |
22 |
Correct |
26 ms |
2620 KB |
Output is correct |
23 |
Correct |
38 ms |
2880 KB |
Output is correct |
24 |
Correct |
34 ms |
2876 KB |
Output is correct |
25 |
Correct |
23 ms |
2916 KB |
Output is correct |
26 |
Correct |
26 ms |
2684 KB |
Output is correct |
27 |
Correct |
34 ms |
3064 KB |
Output is correct |
28 |
Correct |
33 ms |
2964 KB |
Output is correct |
29 |
Correct |
24 ms |
2992 KB |
Output is correct |
30 |
Correct |
22 ms |
2748 KB |
Output is correct |
31 |
Correct |
34 ms |
3048 KB |
Output is correct |
32 |
Correct |
41 ms |
3036 KB |
Output is correct |
33 |
Correct |
25 ms |
3064 KB |
Output is correct |
34 |
Correct |
22 ms |
2876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
712 KB |
Output is correct |
9 |
Correct |
11 ms |
1184 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
9 ms |
904 KB |
Output is correct |
12 |
Correct |
11 ms |
1308 KB |
Output is correct |
13 |
Correct |
9 ms |
1252 KB |
Output is correct |
14 |
Correct |
8 ms |
1252 KB |
Output is correct |
15 |
Correct |
31 ms |
2728 KB |
Output is correct |
16 |
Correct |
31 ms |
2876 KB |
Output is correct |
17 |
Correct |
22 ms |
2812 KB |
Output is correct |
18 |
Correct |
20 ms |
2608 KB |
Output is correct |
19 |
Correct |
40 ms |
2848 KB |
Output is correct |
20 |
Correct |
31 ms |
2896 KB |
Output is correct |
21 |
Correct |
22 ms |
2860 KB |
Output is correct |
22 |
Correct |
26 ms |
2620 KB |
Output is correct |
23 |
Correct |
38 ms |
2880 KB |
Output is correct |
24 |
Correct |
34 ms |
2876 KB |
Output is correct |
25 |
Correct |
23 ms |
2916 KB |
Output is correct |
26 |
Correct |
26 ms |
2684 KB |
Output is correct |
27 |
Correct |
34 ms |
3064 KB |
Output is correct |
28 |
Correct |
33 ms |
2964 KB |
Output is correct |
29 |
Correct |
24 ms |
2992 KB |
Output is correct |
30 |
Correct |
22 ms |
2748 KB |
Output is correct |
31 |
Correct |
34 ms |
3048 KB |
Output is correct |
32 |
Correct |
41 ms |
3036 KB |
Output is correct |
33 |
Correct |
25 ms |
3064 KB |
Output is correct |
34 |
Correct |
22 ms |
2876 KB |
Output is correct |
35 |
Correct |
35 ms |
3080 KB |
Output is correct |
36 |
Correct |
34 ms |
3040 KB |
Output is correct |
37 |
Correct |
25 ms |
3008 KB |
Output is correct |
38 |
Correct |
24 ms |
2872 KB |
Output is correct |