#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
void solve(vector <int> &l, vector <int> &r, bool ok) {
if(l.empty()) {
return ;
}
if(l.size() == 1) {
Answer(l[0], r[0]);
return ;
}
random_shuffle(l.begin(), l.end());
random_shuffle(r.begin(), r.end());
int mid = (0 + l.size()) / 3;
vector <int> l1, l2;
int i, ans = 0;
for(i = 0; i <= mid; i++) {
l1.push_back(l[i]);
ans = Query(l[i]);
}
for(i = mid + 1; i < l.size(); i++) {
l2.push_back(l[i]);
}
vector <int> r1, r2;
for(i = 0; i < r.size(); i++) {
if(r1.size() == l1.size()) {
r2.push_back(r[i]);
continue;
}
if(r2.size() == l2.size()) {
r1.push_back(r[i]);
continue;
}
int cur = Query(r[i]);
if(cur == ans) {
if(ok == 0) {
r1.push_back(r[i]);
}
else {
r2.push_back(r[i]);
}
}
else {
if(ok == 0) {
r2.push_back(r[i]);
}
else {
r1.push_back(r[i]);
}
}
ans = cur;
//Query(r[i]);
}
solve(l1, r1, ok ^ 1);
solve(l2, r2, ok);
}
void Solve(int n) {
srand(time(NULL));
vector <int> l, r;
int ans = 0;
for(int i = 0; i < 2 * n; i++) {
int cur = Query(i + 1);
if(cur == ans) {
l.push_back(i + 1);
}
else {
r.push_back(i + 1);
}
ans = cur;
}
solve(l, r, 1);
}
Compilation message
minerals.cpp: In function 'void solve(std::vector<int>&, std::vector<int>&, bool)':
minerals.cpp:25:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i = mid + 1; i < l.size(); i++) {
~~^~~~~~~~~~
minerals.cpp:29:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i = 0; i < r.size(); i++) {
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
3 |
Correct |
10 ms |
504 KB |
Output is correct |
4 |
Correct |
19 ms |
760 KB |
Output is correct |
5 |
Correct |
37 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
10 ms |
504 KB |
Output is correct |
8 |
Correct |
19 ms |
760 KB |
Output is correct |
9 |
Correct |
37 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
25 ms |
1016 KB |
Output is correct |
12 |
Correct |
36 ms |
1400 KB |
Output is correct |
13 |
Correct |
37 ms |
1400 KB |
Output is correct |
14 |
Correct |
36 ms |
1320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
10 ms |
504 KB |
Output is correct |
8 |
Correct |
19 ms |
760 KB |
Output is correct |
9 |
Correct |
37 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
25 ms |
1016 KB |
Output is correct |
12 |
Correct |
36 ms |
1400 KB |
Output is correct |
13 |
Correct |
37 ms |
1400 KB |
Output is correct |
14 |
Correct |
36 ms |
1320 KB |
Output is correct |
15 |
Correct |
100 ms |
3020 KB |
Output is correct |
16 |
Correct |
100 ms |
2892 KB |
Output is correct |
17 |
Correct |
98 ms |
3028 KB |
Output is correct |
18 |
Correct |
98 ms |
2880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
10 ms |
504 KB |
Output is correct |
8 |
Correct |
19 ms |
760 KB |
Output is correct |
9 |
Correct |
37 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
25 ms |
1016 KB |
Output is correct |
12 |
Correct |
36 ms |
1400 KB |
Output is correct |
13 |
Correct |
37 ms |
1400 KB |
Output is correct |
14 |
Correct |
36 ms |
1320 KB |
Output is correct |
15 |
Correct |
100 ms |
3020 KB |
Output is correct |
16 |
Correct |
100 ms |
2892 KB |
Output is correct |
17 |
Correct |
98 ms |
3028 KB |
Output is correct |
18 |
Correct |
98 ms |
2880 KB |
Output is correct |
19 |
Correct |
106 ms |
3048 KB |
Output is correct |
20 |
Correct |
104 ms |
3048 KB |
Output is correct |
21 |
Correct |
101 ms |
3108 KB |
Output is correct |
22 |
Correct |
100 ms |
2944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
10 ms |
504 KB |
Output is correct |
8 |
Correct |
19 ms |
760 KB |
Output is correct |
9 |
Correct |
37 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
25 ms |
1016 KB |
Output is correct |
12 |
Correct |
36 ms |
1400 KB |
Output is correct |
13 |
Correct |
37 ms |
1400 KB |
Output is correct |
14 |
Correct |
36 ms |
1320 KB |
Output is correct |
15 |
Correct |
100 ms |
3020 KB |
Output is correct |
16 |
Correct |
100 ms |
2892 KB |
Output is correct |
17 |
Correct |
98 ms |
3028 KB |
Output is correct |
18 |
Correct |
98 ms |
2880 KB |
Output is correct |
19 |
Correct |
106 ms |
3048 KB |
Output is correct |
20 |
Correct |
104 ms |
3048 KB |
Output is correct |
21 |
Correct |
101 ms |
3108 KB |
Output is correct |
22 |
Correct |
100 ms |
2944 KB |
Output is correct |
23 |
Correct |
104 ms |
3004 KB |
Output is correct |
24 |
Correct |
106 ms |
3156 KB |
Output is correct |
25 |
Correct |
104 ms |
3004 KB |
Output is correct |
26 |
Correct |
102 ms |
2904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
10 ms |
504 KB |
Output is correct |
8 |
Correct |
19 ms |
760 KB |
Output is correct |
9 |
Correct |
37 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
25 ms |
1016 KB |
Output is correct |
12 |
Correct |
36 ms |
1400 KB |
Output is correct |
13 |
Correct |
37 ms |
1400 KB |
Output is correct |
14 |
Correct |
36 ms |
1320 KB |
Output is correct |
15 |
Correct |
100 ms |
3020 KB |
Output is correct |
16 |
Correct |
100 ms |
2892 KB |
Output is correct |
17 |
Correct |
98 ms |
3028 KB |
Output is correct |
18 |
Correct |
98 ms |
2880 KB |
Output is correct |
19 |
Correct |
106 ms |
3048 KB |
Output is correct |
20 |
Correct |
104 ms |
3048 KB |
Output is correct |
21 |
Correct |
101 ms |
3108 KB |
Output is correct |
22 |
Correct |
100 ms |
2944 KB |
Output is correct |
23 |
Correct |
104 ms |
3004 KB |
Output is correct |
24 |
Correct |
106 ms |
3156 KB |
Output is correct |
25 |
Correct |
104 ms |
3004 KB |
Output is correct |
26 |
Correct |
102 ms |
2904 KB |
Output is correct |
27 |
Correct |
111 ms |
3160 KB |
Output is correct |
28 |
Correct |
110 ms |
3224 KB |
Output is correct |
29 |
Correct |
107 ms |
3136 KB |
Output is correct |
30 |
Correct |
105 ms |
2896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
10 ms |
504 KB |
Output is correct |
8 |
Correct |
19 ms |
760 KB |
Output is correct |
9 |
Correct |
37 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
25 ms |
1016 KB |
Output is correct |
12 |
Correct |
36 ms |
1400 KB |
Output is correct |
13 |
Correct |
37 ms |
1400 KB |
Output is correct |
14 |
Correct |
36 ms |
1320 KB |
Output is correct |
15 |
Correct |
100 ms |
3020 KB |
Output is correct |
16 |
Correct |
100 ms |
2892 KB |
Output is correct |
17 |
Correct |
98 ms |
3028 KB |
Output is correct |
18 |
Correct |
98 ms |
2880 KB |
Output is correct |
19 |
Correct |
106 ms |
3048 KB |
Output is correct |
20 |
Correct |
104 ms |
3048 KB |
Output is correct |
21 |
Correct |
101 ms |
3108 KB |
Output is correct |
22 |
Correct |
100 ms |
2944 KB |
Output is correct |
23 |
Correct |
104 ms |
3004 KB |
Output is correct |
24 |
Correct |
106 ms |
3156 KB |
Output is correct |
25 |
Correct |
104 ms |
3004 KB |
Output is correct |
26 |
Correct |
102 ms |
2904 KB |
Output is correct |
27 |
Correct |
111 ms |
3160 KB |
Output is correct |
28 |
Correct |
110 ms |
3224 KB |
Output is correct |
29 |
Correct |
107 ms |
3136 KB |
Output is correct |
30 |
Correct |
105 ms |
2896 KB |
Output is correct |
31 |
Correct |
112 ms |
3144 KB |
Output is correct |
32 |
Correct |
113 ms |
3220 KB |
Output is correct |
33 |
Correct |
108 ms |
3212 KB |
Output is correct |
34 |
Correct |
110 ms |
3044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
10 ms |
504 KB |
Output is correct |
8 |
Correct |
19 ms |
760 KB |
Output is correct |
9 |
Correct |
37 ms |
1400 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
25 ms |
1016 KB |
Output is correct |
12 |
Correct |
36 ms |
1400 KB |
Output is correct |
13 |
Correct |
37 ms |
1400 KB |
Output is correct |
14 |
Correct |
36 ms |
1320 KB |
Output is correct |
15 |
Correct |
100 ms |
3020 KB |
Output is correct |
16 |
Correct |
100 ms |
2892 KB |
Output is correct |
17 |
Correct |
98 ms |
3028 KB |
Output is correct |
18 |
Correct |
98 ms |
2880 KB |
Output is correct |
19 |
Correct |
106 ms |
3048 KB |
Output is correct |
20 |
Correct |
104 ms |
3048 KB |
Output is correct |
21 |
Correct |
101 ms |
3108 KB |
Output is correct |
22 |
Correct |
100 ms |
2944 KB |
Output is correct |
23 |
Correct |
104 ms |
3004 KB |
Output is correct |
24 |
Correct |
106 ms |
3156 KB |
Output is correct |
25 |
Correct |
104 ms |
3004 KB |
Output is correct |
26 |
Correct |
102 ms |
2904 KB |
Output is correct |
27 |
Correct |
111 ms |
3160 KB |
Output is correct |
28 |
Correct |
110 ms |
3224 KB |
Output is correct |
29 |
Correct |
107 ms |
3136 KB |
Output is correct |
30 |
Correct |
105 ms |
2896 KB |
Output is correct |
31 |
Correct |
112 ms |
3144 KB |
Output is correct |
32 |
Correct |
113 ms |
3220 KB |
Output is correct |
33 |
Correct |
108 ms |
3212 KB |
Output is correct |
34 |
Correct |
110 ms |
3044 KB |
Output is correct |
35 |
Correct |
115 ms |
3232 KB |
Output is correct |
36 |
Correct |
116 ms |
3196 KB |
Output is correct |
37 |
Correct |
111 ms |
3316 KB |
Output is correct |
38 |
Correct |
112 ms |
3016 KB |
Output is correct |