#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
int ret;
void solv(vector <int> v1, vector <int> v2, int in1, int in2){
int sz=v2.size();
if(sz==1){
Answer(v1[0], v2[0]);
return;
}
std::random_shuffle(v1.begin(), v1.end());
vector <int> v11, v12, v21, v22;
int mid=(int)(sz*0.45+0.5);
for(int i=0;i<mid;i++) ret=Query(v1[i]), v11.push_back(v1[i]);
for(int i=mid;i<sz;i++) v12.push_back(v1[i]);
int cur;
for(int i=0;i<sz;i++){
if(v11.size()==v21.size() || v12.size()==v22.size()){
cur=i;
break;
}
int nr=Query(v2[i]);
if(nr==ret){
if(in1==1) v22.push_back(v2[i]);
else v21.push_back(v2[i]);
}
else{
if(in1==1) v21.push_back(v2[i]);
else v22.push_back(v2[i]);
}
ret=nr;
}
for(int i=cur;i<sz;i++){
if(v11.size()!=v21.size()) v21.push_back(v2[i]);
else v22.push_back(v2[i]);
}
solv(v11, v21, 1-in1, 1-in2);
solv(v12, v22, in1, 1-in2);
}
void Solve(int N) {
if(N==1){
Answer(1, 2);
return;
}
ret=0;
vector <int> v1, v2;
for(int i=1;i<=2*N;i++){
int nr=Query(i);
if(nr==ret) v2.push_back(i);
else v1.push_back(i);
ret=nr;
}
solv(v1, v2, 1, 1);
}
Compilation message
minerals.cpp: In function 'void solv(std::vector<int>, std::vector<int>, int, int)':
minerals.cpp:17:9: warning: 'cur' may be used uninitialized in this function [-Wmaybe-uninitialized]
17 | int cur;
| ^~~
# |
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 |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
600 KB |
Output is correct |
3 |
Correct |
3 ms |
600 KB |
Output is correct |
4 |
Correct |
6 ms |
856 KB |
Output is correct |
5 |
Correct |
12 ms |
1368 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 |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
6 ms |
856 KB |
Output is correct |
9 |
Correct |
12 ms |
1368 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
9 ms |
996 KB |
Output is correct |
12 |
Correct |
13 ms |
1624 KB |
Output is correct |
13 |
Correct |
13 ms |
1624 KB |
Output is correct |
14 |
Correct |
17 ms |
1508 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 |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
6 ms |
856 KB |
Output is correct |
9 |
Correct |
12 ms |
1368 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
9 ms |
996 KB |
Output is correct |
12 |
Correct |
13 ms |
1624 KB |
Output is correct |
13 |
Correct |
13 ms |
1624 KB |
Output is correct |
14 |
Correct |
17 ms |
1508 KB |
Output is correct |
15 |
Correct |
35 ms |
3416 KB |
Output is correct |
16 |
Correct |
36 ms |
3408 KB |
Output is correct |
17 |
Correct |
32 ms |
3284 KB |
Output is correct |
18 |
Correct |
34 ms |
3252 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 |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
6 ms |
856 KB |
Output is correct |
9 |
Correct |
12 ms |
1368 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
9 ms |
996 KB |
Output is correct |
12 |
Correct |
13 ms |
1624 KB |
Output is correct |
13 |
Correct |
13 ms |
1624 KB |
Output is correct |
14 |
Correct |
17 ms |
1508 KB |
Output is correct |
15 |
Correct |
35 ms |
3416 KB |
Output is correct |
16 |
Correct |
36 ms |
3408 KB |
Output is correct |
17 |
Correct |
32 ms |
3284 KB |
Output is correct |
18 |
Correct |
34 ms |
3252 KB |
Output is correct |
19 |
Correct |
43 ms |
3408 KB |
Output is correct |
20 |
Correct |
37 ms |
3308 KB |
Output is correct |
21 |
Correct |
34 ms |
3456 KB |
Output is correct |
22 |
Correct |
35 ms |
3152 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 |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
6 ms |
856 KB |
Output is correct |
9 |
Correct |
12 ms |
1368 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
9 ms |
996 KB |
Output is correct |
12 |
Correct |
13 ms |
1624 KB |
Output is correct |
13 |
Correct |
13 ms |
1624 KB |
Output is correct |
14 |
Correct |
17 ms |
1508 KB |
Output is correct |
15 |
Correct |
35 ms |
3416 KB |
Output is correct |
16 |
Correct |
36 ms |
3408 KB |
Output is correct |
17 |
Correct |
32 ms |
3284 KB |
Output is correct |
18 |
Correct |
34 ms |
3252 KB |
Output is correct |
19 |
Correct |
43 ms |
3408 KB |
Output is correct |
20 |
Correct |
37 ms |
3308 KB |
Output is correct |
21 |
Correct |
34 ms |
3456 KB |
Output is correct |
22 |
Correct |
35 ms |
3152 KB |
Output is correct |
23 |
Correct |
38 ms |
3412 KB |
Output is correct |
24 |
Correct |
36 ms |
3416 KB |
Output is correct |
25 |
Correct |
37 ms |
3312 KB |
Output is correct |
26 |
Correct |
36 ms |
3396 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 |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
6 ms |
856 KB |
Output is correct |
9 |
Correct |
12 ms |
1368 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
9 ms |
996 KB |
Output is correct |
12 |
Correct |
13 ms |
1624 KB |
Output is correct |
13 |
Correct |
13 ms |
1624 KB |
Output is correct |
14 |
Correct |
17 ms |
1508 KB |
Output is correct |
15 |
Correct |
35 ms |
3416 KB |
Output is correct |
16 |
Correct |
36 ms |
3408 KB |
Output is correct |
17 |
Correct |
32 ms |
3284 KB |
Output is correct |
18 |
Correct |
34 ms |
3252 KB |
Output is correct |
19 |
Correct |
43 ms |
3408 KB |
Output is correct |
20 |
Correct |
37 ms |
3308 KB |
Output is correct |
21 |
Correct |
34 ms |
3456 KB |
Output is correct |
22 |
Correct |
35 ms |
3152 KB |
Output is correct |
23 |
Correct |
38 ms |
3412 KB |
Output is correct |
24 |
Correct |
36 ms |
3416 KB |
Output is correct |
25 |
Correct |
37 ms |
3312 KB |
Output is correct |
26 |
Correct |
36 ms |
3396 KB |
Output is correct |
27 |
Correct |
38 ms |
3568 KB |
Output is correct |
28 |
Correct |
37 ms |
3624 KB |
Output is correct |
29 |
Correct |
35 ms |
3504 KB |
Output is correct |
30 |
Correct |
41 ms |
3404 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 |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
6 ms |
856 KB |
Output is correct |
9 |
Correct |
12 ms |
1368 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
9 ms |
996 KB |
Output is correct |
12 |
Correct |
13 ms |
1624 KB |
Output is correct |
13 |
Correct |
13 ms |
1624 KB |
Output is correct |
14 |
Correct |
17 ms |
1508 KB |
Output is correct |
15 |
Correct |
35 ms |
3416 KB |
Output is correct |
16 |
Correct |
36 ms |
3408 KB |
Output is correct |
17 |
Correct |
32 ms |
3284 KB |
Output is correct |
18 |
Correct |
34 ms |
3252 KB |
Output is correct |
19 |
Correct |
43 ms |
3408 KB |
Output is correct |
20 |
Correct |
37 ms |
3308 KB |
Output is correct |
21 |
Correct |
34 ms |
3456 KB |
Output is correct |
22 |
Correct |
35 ms |
3152 KB |
Output is correct |
23 |
Correct |
38 ms |
3412 KB |
Output is correct |
24 |
Correct |
36 ms |
3416 KB |
Output is correct |
25 |
Correct |
37 ms |
3312 KB |
Output is correct |
26 |
Correct |
36 ms |
3396 KB |
Output is correct |
27 |
Correct |
38 ms |
3568 KB |
Output is correct |
28 |
Correct |
37 ms |
3624 KB |
Output is correct |
29 |
Correct |
35 ms |
3504 KB |
Output is correct |
30 |
Correct |
41 ms |
3404 KB |
Output is correct |
31 |
Correct |
48 ms |
3576 KB |
Output is correct |
32 |
Correct |
39 ms |
3676 KB |
Output is correct |
33 |
Correct |
41 ms |
3540 KB |
Output is correct |
34 |
Correct |
39 ms |
3584 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 |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
600 KB |
Output is correct |
7 |
Correct |
3 ms |
600 KB |
Output is correct |
8 |
Correct |
6 ms |
856 KB |
Output is correct |
9 |
Correct |
12 ms |
1368 KB |
Output is correct |
10 |
Correct |
1 ms |
596 KB |
Output is correct |
11 |
Correct |
9 ms |
996 KB |
Output is correct |
12 |
Correct |
13 ms |
1624 KB |
Output is correct |
13 |
Correct |
13 ms |
1624 KB |
Output is correct |
14 |
Correct |
17 ms |
1508 KB |
Output is correct |
15 |
Correct |
35 ms |
3416 KB |
Output is correct |
16 |
Correct |
36 ms |
3408 KB |
Output is correct |
17 |
Correct |
32 ms |
3284 KB |
Output is correct |
18 |
Correct |
34 ms |
3252 KB |
Output is correct |
19 |
Correct |
43 ms |
3408 KB |
Output is correct |
20 |
Correct |
37 ms |
3308 KB |
Output is correct |
21 |
Correct |
34 ms |
3456 KB |
Output is correct |
22 |
Correct |
35 ms |
3152 KB |
Output is correct |
23 |
Correct |
38 ms |
3412 KB |
Output is correct |
24 |
Correct |
36 ms |
3416 KB |
Output is correct |
25 |
Correct |
37 ms |
3312 KB |
Output is correct |
26 |
Correct |
36 ms |
3396 KB |
Output is correct |
27 |
Correct |
38 ms |
3568 KB |
Output is correct |
28 |
Correct |
37 ms |
3624 KB |
Output is correct |
29 |
Correct |
35 ms |
3504 KB |
Output is correct |
30 |
Correct |
41 ms |
3404 KB |
Output is correct |
31 |
Correct |
48 ms |
3576 KB |
Output is correct |
32 |
Correct |
39 ms |
3676 KB |
Output is correct |
33 |
Correct |
41 ms |
3540 KB |
Output is correct |
34 |
Correct |
39 ms |
3584 KB |
Output is correct |
35 |
Correct |
49 ms |
3756 KB |
Output is correct |
36 |
Correct |
38 ms |
3580 KB |
Output is correct |
37 |
Correct |
43 ms |
3728 KB |
Output is correct |
38 |
Correct |
38 ms |
3552 KB |
Output is correct |