#include <bits/stdc++.h>
#include "minerals.h"
using namespace std;
#define rep(x,s,e) for (auto x=s;x<e;x++)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
set<int> in;
int query(int i){
if (in.count(i)) in.erase(i);
else in.insert(i);
return Query(i);
}
int curr=0;
void rec(vector<int> v1,vector<int> v2,int flag){
//0-in out
//1-in in
//2-out out
/*
for (auto &it:v1) cout<<it<<" ";cout<<endl;
for (auto &it:v2) cout<<it<<" ";cout<<endl;
for (auto &it:in) cout<<it<<" ";cout<<endl;
cout<<endl;
//*/
if (sz(v1)==1){
Answer(v1[0],v2[0]);
return;
}
vector<int> l1,l2,r1,r2;
int half;
if (flag!=2) half=sz(v1)*0.62;
else half=ceil(sz(v1)*0.38);
rep(x,0,half){
if (flag==2) curr=query(v1[x]);
l1.push_back(v1[x]);
}
rep(x,half,sz(v1)){
if (flag!=2) curr=query(v1[x]);
r1.push_back(v1[x]);
}
if (flag!=1){
for (auto &it:v2){
int temp=query(it);
if (temp==curr){
l2.push_back(it);
}
else{
r2.push_back(it);
}
curr=temp;
}
rec(l1,l2,1),rec(r2,r1,0);
}
else{
for (auto &it:v2){
int temp=query(it);
if (temp==curr){
l2.push_back(it);
}
else{
r2.push_back(it);
}
curr=temp;
}
rec(l1,l2,0),rec(r1,r2,2);
}
}
void Solve(int n) {
vector<int> v1,v2;
rep(x,1,2*n+1){
int temp=query(x);
if (temp==curr){
v2.push_back(x);
}
else{
v1.push_back(x);
}
curr=temp;
}
rec(v1,v2,1);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
512 KB |
Output is correct |
2 |
Correct |
9 ms |
640 KB |
Output is correct |
3 |
Correct |
19 ms |
1004 KB |
Output is correct |
4 |
Correct |
43 ms |
1560 KB |
Output is correct |
5 |
Correct |
92 ms |
2432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
512 KB |
Output is correct |
6 |
Correct |
9 ms |
640 KB |
Output is correct |
7 |
Correct |
19 ms |
1004 KB |
Output is correct |
8 |
Correct |
43 ms |
1560 KB |
Output is correct |
9 |
Correct |
92 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
58 ms |
1792 KB |
Output is correct |
12 |
Correct |
89 ms |
2560 KB |
Output is correct |
13 |
Correct |
74 ms |
2680 KB |
Output is correct |
14 |
Correct |
66 ms |
2432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
512 KB |
Output is correct |
6 |
Correct |
9 ms |
640 KB |
Output is correct |
7 |
Correct |
19 ms |
1004 KB |
Output is correct |
8 |
Correct |
43 ms |
1560 KB |
Output is correct |
9 |
Correct |
92 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
58 ms |
1792 KB |
Output is correct |
12 |
Correct |
89 ms |
2560 KB |
Output is correct |
13 |
Correct |
74 ms |
2680 KB |
Output is correct |
14 |
Correct |
66 ms |
2432 KB |
Output is correct |
15 |
Correct |
264 ms |
5876 KB |
Output is correct |
16 |
Correct |
261 ms |
6004 KB |
Output is correct |
17 |
Correct |
203 ms |
6128 KB |
Output is correct |
18 |
Correct |
194 ms |
5748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
512 KB |
Output is correct |
6 |
Correct |
9 ms |
640 KB |
Output is correct |
7 |
Correct |
19 ms |
1004 KB |
Output is correct |
8 |
Correct |
43 ms |
1560 KB |
Output is correct |
9 |
Correct |
92 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
58 ms |
1792 KB |
Output is correct |
12 |
Correct |
89 ms |
2560 KB |
Output is correct |
13 |
Correct |
74 ms |
2680 KB |
Output is correct |
14 |
Correct |
66 ms |
2432 KB |
Output is correct |
15 |
Correct |
264 ms |
5876 KB |
Output is correct |
16 |
Correct |
261 ms |
6004 KB |
Output is correct |
17 |
Correct |
203 ms |
6128 KB |
Output is correct |
18 |
Correct |
194 ms |
5748 KB |
Output is correct |
19 |
Correct |
277 ms |
6056 KB |
Output is correct |
20 |
Correct |
270 ms |
6132 KB |
Output is correct |
21 |
Correct |
203 ms |
6256 KB |
Output is correct |
22 |
Correct |
198 ms |
5876 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
512 KB |
Output is correct |
6 |
Correct |
9 ms |
640 KB |
Output is correct |
7 |
Correct |
19 ms |
1004 KB |
Output is correct |
8 |
Correct |
43 ms |
1560 KB |
Output is correct |
9 |
Correct |
92 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
58 ms |
1792 KB |
Output is correct |
12 |
Correct |
89 ms |
2560 KB |
Output is correct |
13 |
Correct |
74 ms |
2680 KB |
Output is correct |
14 |
Correct |
66 ms |
2432 KB |
Output is correct |
15 |
Correct |
264 ms |
5876 KB |
Output is correct |
16 |
Correct |
261 ms |
6004 KB |
Output is correct |
17 |
Correct |
203 ms |
6128 KB |
Output is correct |
18 |
Correct |
194 ms |
5748 KB |
Output is correct |
19 |
Correct |
277 ms |
6056 KB |
Output is correct |
20 |
Correct |
270 ms |
6132 KB |
Output is correct |
21 |
Correct |
203 ms |
6256 KB |
Output is correct |
22 |
Correct |
198 ms |
5876 KB |
Output is correct |
23 |
Correct |
296 ms |
6388 KB |
Output is correct |
24 |
Correct |
277 ms |
6260 KB |
Output is correct |
25 |
Correct |
212 ms |
6424 KB |
Output is correct |
26 |
Correct |
202 ms |
6132 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
512 KB |
Output is correct |
6 |
Correct |
9 ms |
640 KB |
Output is correct |
7 |
Correct |
19 ms |
1004 KB |
Output is correct |
8 |
Correct |
43 ms |
1560 KB |
Output is correct |
9 |
Correct |
92 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
58 ms |
1792 KB |
Output is correct |
12 |
Correct |
89 ms |
2560 KB |
Output is correct |
13 |
Correct |
74 ms |
2680 KB |
Output is correct |
14 |
Correct |
66 ms |
2432 KB |
Output is correct |
15 |
Correct |
264 ms |
5876 KB |
Output is correct |
16 |
Correct |
261 ms |
6004 KB |
Output is correct |
17 |
Correct |
203 ms |
6128 KB |
Output is correct |
18 |
Correct |
194 ms |
5748 KB |
Output is correct |
19 |
Correct |
277 ms |
6056 KB |
Output is correct |
20 |
Correct |
270 ms |
6132 KB |
Output is correct |
21 |
Correct |
203 ms |
6256 KB |
Output is correct |
22 |
Correct |
198 ms |
5876 KB |
Output is correct |
23 |
Correct |
296 ms |
6388 KB |
Output is correct |
24 |
Correct |
277 ms |
6260 KB |
Output is correct |
25 |
Correct |
212 ms |
6424 KB |
Output is correct |
26 |
Correct |
202 ms |
6132 KB |
Output is correct |
27 |
Correct |
310 ms |
6416 KB |
Output is correct |
28 |
Correct |
282 ms |
6388 KB |
Output is correct |
29 |
Correct |
225 ms |
6512 KB |
Output is correct |
30 |
Correct |
209 ms |
6260 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
512 KB |
Output is correct |
6 |
Correct |
9 ms |
640 KB |
Output is correct |
7 |
Correct |
19 ms |
1004 KB |
Output is correct |
8 |
Correct |
43 ms |
1560 KB |
Output is correct |
9 |
Correct |
92 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
58 ms |
1792 KB |
Output is correct |
12 |
Correct |
89 ms |
2560 KB |
Output is correct |
13 |
Correct |
74 ms |
2680 KB |
Output is correct |
14 |
Correct |
66 ms |
2432 KB |
Output is correct |
15 |
Correct |
264 ms |
5876 KB |
Output is correct |
16 |
Correct |
261 ms |
6004 KB |
Output is correct |
17 |
Correct |
203 ms |
6128 KB |
Output is correct |
18 |
Correct |
194 ms |
5748 KB |
Output is correct |
19 |
Correct |
277 ms |
6056 KB |
Output is correct |
20 |
Correct |
270 ms |
6132 KB |
Output is correct |
21 |
Correct |
203 ms |
6256 KB |
Output is correct |
22 |
Correct |
198 ms |
5876 KB |
Output is correct |
23 |
Correct |
296 ms |
6388 KB |
Output is correct |
24 |
Correct |
277 ms |
6260 KB |
Output is correct |
25 |
Correct |
212 ms |
6424 KB |
Output is correct |
26 |
Correct |
202 ms |
6132 KB |
Output is correct |
27 |
Correct |
310 ms |
6416 KB |
Output is correct |
28 |
Correct |
282 ms |
6388 KB |
Output is correct |
29 |
Correct |
225 ms |
6512 KB |
Output is correct |
30 |
Correct |
209 ms |
6260 KB |
Output is correct |
31 |
Incorrect |
284 ms |
6516 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
512 KB |
Output is correct |
6 |
Correct |
9 ms |
640 KB |
Output is correct |
7 |
Correct |
19 ms |
1004 KB |
Output is correct |
8 |
Correct |
43 ms |
1560 KB |
Output is correct |
9 |
Correct |
92 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
58 ms |
1792 KB |
Output is correct |
12 |
Correct |
89 ms |
2560 KB |
Output is correct |
13 |
Correct |
74 ms |
2680 KB |
Output is correct |
14 |
Correct |
66 ms |
2432 KB |
Output is correct |
15 |
Correct |
264 ms |
5876 KB |
Output is correct |
16 |
Correct |
261 ms |
6004 KB |
Output is correct |
17 |
Correct |
203 ms |
6128 KB |
Output is correct |
18 |
Correct |
194 ms |
5748 KB |
Output is correct |
19 |
Correct |
277 ms |
6056 KB |
Output is correct |
20 |
Correct |
270 ms |
6132 KB |
Output is correct |
21 |
Correct |
203 ms |
6256 KB |
Output is correct |
22 |
Correct |
198 ms |
5876 KB |
Output is correct |
23 |
Correct |
296 ms |
6388 KB |
Output is correct |
24 |
Correct |
277 ms |
6260 KB |
Output is correct |
25 |
Correct |
212 ms |
6424 KB |
Output is correct |
26 |
Correct |
202 ms |
6132 KB |
Output is correct |
27 |
Correct |
310 ms |
6416 KB |
Output is correct |
28 |
Correct |
282 ms |
6388 KB |
Output is correct |
29 |
Correct |
225 ms |
6512 KB |
Output is correct |
30 |
Correct |
209 ms |
6260 KB |
Output is correct |
31 |
Incorrect |
284 ms |
6516 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |