#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]);
if (flag!=2) curr=query(v1[0]);
if (flag==1) curr=query(v2[0]);
return;
}
vector<int> l1,l2,r1,r2;
int half=sz(v1)/2;
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);
}
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
512 KB |
Output is correct |
2 |
Correct |
9 ms |
640 KB |
Output is correct |
3 |
Correct |
17 ms |
896 KB |
Output is correct |
4 |
Correct |
39 ms |
1408 KB |
Output is correct |
5 |
Correct |
84 ms |
2432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
17 ms |
896 KB |
Output is correct |
8 |
Correct |
39 ms |
1408 KB |
Output is correct |
9 |
Correct |
84 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
52 ms |
1792 KB |
Output is correct |
12 |
Correct |
83 ms |
2560 KB |
Output is correct |
13 |
Correct |
68 ms |
2560 KB |
Output is correct |
14 |
Correct |
63 ms |
2424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
17 ms |
896 KB |
Output is correct |
8 |
Correct |
39 ms |
1408 KB |
Output is correct |
9 |
Correct |
84 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
52 ms |
1792 KB |
Output is correct |
12 |
Correct |
83 ms |
2560 KB |
Output is correct |
13 |
Correct |
68 ms |
2560 KB |
Output is correct |
14 |
Correct |
63 ms |
2424 KB |
Output is correct |
15 |
Correct |
250 ms |
6004 KB |
Output is correct |
16 |
Correct |
249 ms |
6004 KB |
Output is correct |
17 |
Correct |
195 ms |
6000 KB |
Output is correct |
18 |
Correct |
182 ms |
5836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
17 ms |
896 KB |
Output is correct |
8 |
Correct |
39 ms |
1408 KB |
Output is correct |
9 |
Correct |
84 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
52 ms |
1792 KB |
Output is correct |
12 |
Correct |
83 ms |
2560 KB |
Output is correct |
13 |
Correct |
68 ms |
2560 KB |
Output is correct |
14 |
Correct |
63 ms |
2424 KB |
Output is correct |
15 |
Correct |
250 ms |
6004 KB |
Output is correct |
16 |
Correct |
249 ms |
6004 KB |
Output is correct |
17 |
Correct |
195 ms |
6000 KB |
Output is correct |
18 |
Correct |
182 ms |
5836 KB |
Output is correct |
19 |
Incorrect |
250 ms |
6260 KB |
Wrong Answer [2] |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
17 ms |
896 KB |
Output is correct |
8 |
Correct |
39 ms |
1408 KB |
Output is correct |
9 |
Correct |
84 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
52 ms |
1792 KB |
Output is correct |
12 |
Correct |
83 ms |
2560 KB |
Output is correct |
13 |
Correct |
68 ms |
2560 KB |
Output is correct |
14 |
Correct |
63 ms |
2424 KB |
Output is correct |
15 |
Correct |
250 ms |
6004 KB |
Output is correct |
16 |
Correct |
249 ms |
6004 KB |
Output is correct |
17 |
Correct |
195 ms |
6000 KB |
Output is correct |
18 |
Correct |
182 ms |
5836 KB |
Output is correct |
19 |
Incorrect |
250 ms |
6260 KB |
Wrong Answer [2] |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
17 ms |
896 KB |
Output is correct |
8 |
Correct |
39 ms |
1408 KB |
Output is correct |
9 |
Correct |
84 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
52 ms |
1792 KB |
Output is correct |
12 |
Correct |
83 ms |
2560 KB |
Output is correct |
13 |
Correct |
68 ms |
2560 KB |
Output is correct |
14 |
Correct |
63 ms |
2424 KB |
Output is correct |
15 |
Correct |
250 ms |
6004 KB |
Output is correct |
16 |
Correct |
249 ms |
6004 KB |
Output is correct |
17 |
Correct |
195 ms |
6000 KB |
Output is correct |
18 |
Correct |
182 ms |
5836 KB |
Output is correct |
19 |
Incorrect |
250 ms |
6260 KB |
Wrong Answer [2] |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
17 ms |
896 KB |
Output is correct |
8 |
Correct |
39 ms |
1408 KB |
Output is correct |
9 |
Correct |
84 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
52 ms |
1792 KB |
Output is correct |
12 |
Correct |
83 ms |
2560 KB |
Output is correct |
13 |
Correct |
68 ms |
2560 KB |
Output is correct |
14 |
Correct |
63 ms |
2424 KB |
Output is correct |
15 |
Correct |
250 ms |
6004 KB |
Output is correct |
16 |
Correct |
249 ms |
6004 KB |
Output is correct |
17 |
Correct |
195 ms |
6000 KB |
Output is correct |
18 |
Correct |
182 ms |
5836 KB |
Output is correct |
19 |
Incorrect |
250 ms |
6260 KB |
Wrong Answer [2] |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
17 ms |
896 KB |
Output is correct |
8 |
Correct |
39 ms |
1408 KB |
Output is correct |
9 |
Correct |
84 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
52 ms |
1792 KB |
Output is correct |
12 |
Correct |
83 ms |
2560 KB |
Output is correct |
13 |
Correct |
68 ms |
2560 KB |
Output is correct |
14 |
Correct |
63 ms |
2424 KB |
Output is correct |
15 |
Correct |
250 ms |
6004 KB |
Output is correct |
16 |
Correct |
249 ms |
6004 KB |
Output is correct |
17 |
Correct |
195 ms |
6000 KB |
Output is correct |
18 |
Correct |
182 ms |
5836 KB |
Output is correct |
19 |
Incorrect |
250 ms |
6260 KB |
Wrong Answer [2] |
20 |
Halted |
0 ms |
0 KB |
- |