#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;
set<int>st;
int query(int k){
if(st.count(k))
st.erase(k);
else st.insert(k);
return Query(k);
}
mt19937 rng(random_device{}());
void solve(vector<int>A,vector<int>B,int dep){
if(A.size()==1) return Answer(A[0],B[0]);
vector<int>A1,A2;
vector<int>B1,B2;
for(auto i:A)
A1.push_back(i),swap(A1,A2);
int prv=0;
for(auto i:A1)
prv=query(i);
shuffle(B.begin(),B.end(),rng);
for(auto i:B) {
if(A1.size()==B1.size()){
B2.push_back(i);
continue;
} else if(A2.size()==B2.size()){
B1.push_back(i);
continue;
}
int x=query(i);
if(st.count(A1[0])^(x==prv))
B2.push_back(i);
else B1.push_back(i);
prv=x;
}
solve(A1,B1,dep^1);
solve(A2,B2,dep^1);
}
void Solve(int N) {
vector<int>A,B;
int prv=0;
vector<int>VV(2*N);
iota(VV.begin(),VV.end(),1);
shuffle(VV.begin(),VV.end(),rng);
for(auto i:VV) {
if(A.size()==N){
B.push_back(i);
continue;
} else if(B.size()==N){
A.push_back(i);
continue;
}
if(query(i)!=prv)
A.push_back(i),prv++;
else B.push_back(i);
}
solve(A,B,0);
}
Compilation message
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:46:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
46 | if(A.size()==N){
| ~~~~~~~~^~~
minerals.cpp:49:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
49 | } else if(B.size()==N){
| ~~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
600 KB |
Output is correct |
2 |
Correct |
6 ms |
780 KB |
Output is correct |
3 |
Correct |
16 ms |
1112 KB |
Output is correct |
4 |
Correct |
40 ms |
1624 KB |
Output is correct |
5 |
Correct |
108 ms |
2952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
600 KB |
Output is correct |
6 |
Correct |
6 ms |
780 KB |
Output is correct |
7 |
Correct |
16 ms |
1112 KB |
Output is correct |
8 |
Correct |
40 ms |
1624 KB |
Output is correct |
9 |
Correct |
108 ms |
2952 KB |
Output is correct |
10 |
Correct |
3 ms |
600 KB |
Output is correct |
11 |
Correct |
53 ms |
1984 KB |
Output is correct |
12 |
Correct |
88 ms |
2896 KB |
Output is correct |
13 |
Correct |
83 ms |
2904 KB |
Output is correct |
14 |
Correct |
89 ms |
2772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
600 KB |
Output is correct |
6 |
Correct |
6 ms |
780 KB |
Output is correct |
7 |
Correct |
16 ms |
1112 KB |
Output is correct |
8 |
Correct |
40 ms |
1624 KB |
Output is correct |
9 |
Correct |
108 ms |
2952 KB |
Output is correct |
10 |
Correct |
3 ms |
600 KB |
Output is correct |
11 |
Correct |
53 ms |
1984 KB |
Output is correct |
12 |
Correct |
88 ms |
2896 KB |
Output is correct |
13 |
Correct |
83 ms |
2904 KB |
Output is correct |
14 |
Correct |
89 ms |
2772 KB |
Output is correct |
15 |
Correct |
288 ms |
7032 KB |
Output is correct |
16 |
Correct |
291 ms |
7000 KB |
Output is correct |
17 |
Correct |
276 ms |
7052 KB |
Output is correct |
18 |
Correct |
293 ms |
6856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
600 KB |
Output is correct |
6 |
Correct |
6 ms |
780 KB |
Output is correct |
7 |
Correct |
16 ms |
1112 KB |
Output is correct |
8 |
Correct |
40 ms |
1624 KB |
Output is correct |
9 |
Correct |
108 ms |
2952 KB |
Output is correct |
10 |
Correct |
3 ms |
600 KB |
Output is correct |
11 |
Correct |
53 ms |
1984 KB |
Output is correct |
12 |
Correct |
88 ms |
2896 KB |
Output is correct |
13 |
Correct |
83 ms |
2904 KB |
Output is correct |
14 |
Correct |
89 ms |
2772 KB |
Output is correct |
15 |
Correct |
288 ms |
7032 KB |
Output is correct |
16 |
Correct |
291 ms |
7000 KB |
Output is correct |
17 |
Correct |
276 ms |
7052 KB |
Output is correct |
18 |
Correct |
293 ms |
6856 KB |
Output is correct |
19 |
Correct |
297 ms |
7192 KB |
Output is correct |
20 |
Correct |
305 ms |
7168 KB |
Output is correct |
21 |
Correct |
291 ms |
7168 KB |
Output is correct |
22 |
Correct |
306 ms |
7056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
600 KB |
Output is correct |
6 |
Correct |
6 ms |
780 KB |
Output is correct |
7 |
Correct |
16 ms |
1112 KB |
Output is correct |
8 |
Correct |
40 ms |
1624 KB |
Output is correct |
9 |
Correct |
108 ms |
2952 KB |
Output is correct |
10 |
Correct |
3 ms |
600 KB |
Output is correct |
11 |
Correct |
53 ms |
1984 KB |
Output is correct |
12 |
Correct |
88 ms |
2896 KB |
Output is correct |
13 |
Correct |
83 ms |
2904 KB |
Output is correct |
14 |
Correct |
89 ms |
2772 KB |
Output is correct |
15 |
Correct |
288 ms |
7032 KB |
Output is correct |
16 |
Correct |
291 ms |
7000 KB |
Output is correct |
17 |
Correct |
276 ms |
7052 KB |
Output is correct |
18 |
Correct |
293 ms |
6856 KB |
Output is correct |
19 |
Correct |
297 ms |
7192 KB |
Output is correct |
20 |
Correct |
305 ms |
7168 KB |
Output is correct |
21 |
Correct |
291 ms |
7168 KB |
Output is correct |
22 |
Correct |
306 ms |
7056 KB |
Output is correct |
23 |
Correct |
314 ms |
7408 KB |
Output is correct |
24 |
Correct |
299 ms |
7288 KB |
Output is correct |
25 |
Correct |
290 ms |
7416 KB |
Output is correct |
26 |
Correct |
299 ms |
7200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
600 KB |
Output is correct |
6 |
Correct |
6 ms |
780 KB |
Output is correct |
7 |
Correct |
16 ms |
1112 KB |
Output is correct |
8 |
Correct |
40 ms |
1624 KB |
Output is correct |
9 |
Correct |
108 ms |
2952 KB |
Output is correct |
10 |
Correct |
3 ms |
600 KB |
Output is correct |
11 |
Correct |
53 ms |
1984 KB |
Output is correct |
12 |
Correct |
88 ms |
2896 KB |
Output is correct |
13 |
Correct |
83 ms |
2904 KB |
Output is correct |
14 |
Correct |
89 ms |
2772 KB |
Output is correct |
15 |
Correct |
288 ms |
7032 KB |
Output is correct |
16 |
Correct |
291 ms |
7000 KB |
Output is correct |
17 |
Correct |
276 ms |
7052 KB |
Output is correct |
18 |
Correct |
293 ms |
6856 KB |
Output is correct |
19 |
Correct |
297 ms |
7192 KB |
Output is correct |
20 |
Correct |
305 ms |
7168 KB |
Output is correct |
21 |
Correct |
291 ms |
7168 KB |
Output is correct |
22 |
Correct |
306 ms |
7056 KB |
Output is correct |
23 |
Correct |
314 ms |
7408 KB |
Output is correct |
24 |
Correct |
299 ms |
7288 KB |
Output is correct |
25 |
Correct |
290 ms |
7416 KB |
Output is correct |
26 |
Correct |
299 ms |
7200 KB |
Output is correct |
27 |
Correct |
310 ms |
7520 KB |
Output is correct |
28 |
Correct |
311 ms |
7556 KB |
Output is correct |
29 |
Correct |
335 ms |
7588 KB |
Output is correct |
30 |
Correct |
319 ms |
7372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
600 KB |
Output is correct |
6 |
Correct |
6 ms |
780 KB |
Output is correct |
7 |
Correct |
16 ms |
1112 KB |
Output is correct |
8 |
Correct |
40 ms |
1624 KB |
Output is correct |
9 |
Correct |
108 ms |
2952 KB |
Output is correct |
10 |
Correct |
3 ms |
600 KB |
Output is correct |
11 |
Correct |
53 ms |
1984 KB |
Output is correct |
12 |
Correct |
88 ms |
2896 KB |
Output is correct |
13 |
Correct |
83 ms |
2904 KB |
Output is correct |
14 |
Correct |
89 ms |
2772 KB |
Output is correct |
15 |
Correct |
288 ms |
7032 KB |
Output is correct |
16 |
Correct |
291 ms |
7000 KB |
Output is correct |
17 |
Correct |
276 ms |
7052 KB |
Output is correct |
18 |
Correct |
293 ms |
6856 KB |
Output is correct |
19 |
Correct |
297 ms |
7192 KB |
Output is correct |
20 |
Correct |
305 ms |
7168 KB |
Output is correct |
21 |
Correct |
291 ms |
7168 KB |
Output is correct |
22 |
Correct |
306 ms |
7056 KB |
Output is correct |
23 |
Correct |
314 ms |
7408 KB |
Output is correct |
24 |
Correct |
299 ms |
7288 KB |
Output is correct |
25 |
Correct |
290 ms |
7416 KB |
Output is correct |
26 |
Correct |
299 ms |
7200 KB |
Output is correct |
27 |
Correct |
310 ms |
7520 KB |
Output is correct |
28 |
Correct |
311 ms |
7556 KB |
Output is correct |
29 |
Correct |
335 ms |
7588 KB |
Output is correct |
30 |
Correct |
319 ms |
7372 KB |
Output is correct |
31 |
Correct |
327 ms |
7668 KB |
Output is correct |
32 |
Correct |
334 ms |
7724 KB |
Output is correct |
33 |
Correct |
314 ms |
7664 KB |
Output is correct |
34 |
Correct |
351 ms |
7584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
600 KB |
Output is correct |
6 |
Correct |
6 ms |
780 KB |
Output is correct |
7 |
Correct |
16 ms |
1112 KB |
Output is correct |
8 |
Correct |
40 ms |
1624 KB |
Output is correct |
9 |
Correct |
108 ms |
2952 KB |
Output is correct |
10 |
Correct |
3 ms |
600 KB |
Output is correct |
11 |
Correct |
53 ms |
1984 KB |
Output is correct |
12 |
Correct |
88 ms |
2896 KB |
Output is correct |
13 |
Correct |
83 ms |
2904 KB |
Output is correct |
14 |
Correct |
89 ms |
2772 KB |
Output is correct |
15 |
Correct |
288 ms |
7032 KB |
Output is correct |
16 |
Correct |
291 ms |
7000 KB |
Output is correct |
17 |
Correct |
276 ms |
7052 KB |
Output is correct |
18 |
Correct |
293 ms |
6856 KB |
Output is correct |
19 |
Correct |
297 ms |
7192 KB |
Output is correct |
20 |
Correct |
305 ms |
7168 KB |
Output is correct |
21 |
Correct |
291 ms |
7168 KB |
Output is correct |
22 |
Correct |
306 ms |
7056 KB |
Output is correct |
23 |
Correct |
314 ms |
7408 KB |
Output is correct |
24 |
Correct |
299 ms |
7288 KB |
Output is correct |
25 |
Correct |
290 ms |
7416 KB |
Output is correct |
26 |
Correct |
299 ms |
7200 KB |
Output is correct |
27 |
Correct |
310 ms |
7520 KB |
Output is correct |
28 |
Correct |
311 ms |
7556 KB |
Output is correct |
29 |
Correct |
335 ms |
7588 KB |
Output is correct |
30 |
Correct |
319 ms |
7372 KB |
Output is correct |
31 |
Correct |
327 ms |
7668 KB |
Output is correct |
32 |
Correct |
334 ms |
7724 KB |
Output is correct |
33 |
Correct |
314 ms |
7664 KB |
Output is correct |
34 |
Correct |
351 ms |
7584 KB |
Output is correct |
35 |
Incorrect |
332 ms |
7920 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |