#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;
bool inside[1000005];
int past = 0;
void solve(vector<int> a, vector<int> b) {
if(a.size() == 1) {
Answer(a[0], b[0]);
} else {
random_shuffle(b.begin(), b.end());
vector<int> a1, a2, b1, b2;
for(int i=0; i<a.size()/2; i++) {
if(!inside[a[i]]) {
inside[a[i]] = !inside[a[i]];
past = Query(a[i]);
}
a1.push_back(a[i]);
}
for(int i=a.size()/2; i<a.size(); i++) {
if(inside[a[i]]) {
inside[a[i]] = !inside[a[i]];
past = Query(a[i]);
}
a2.push_back(a[i]);
}
for(int i=0; i<b.size(); i++) {
if(b1.size() == a1.size()) {
b2.push_back(b[i]);
} else if(b2.size() == a2.size()) {
b1.push_back(b[i]);
} else {
int curr;
inside[b[i]] = !inside[b[i]];
curr = Query(b[i]);
if(curr == past) {
b1.push_back(b[i]);
} else {
b2.push_back(b[i]);
}
past = curr;
}
}
solve(a1, b1);
solve(a2, b2);
}
}
vector<int> t1,t2;
void Solve(int N) {
// TODO: Implement your solution here
for(int i=1; i<=2*N; i++) {
inside[i] = !inside[i];
int curr = Query(i);
if(curr == past) t2.push_back(i);
else t1.push_back(i);
past = curr;
}
solve(t1, t2);
}
Compilation message
minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>)':
minerals.cpp:14:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for(int i=0; i<a.size()/2; i++) {
| ~^~~~~~~~~~~
minerals.cpp:21:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | for(int i=a.size()/2; i<a.size(); i++) {
| ~^~~~~~~~~
minerals.cpp:28:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for(int i=0; i<b.size(); i++) {
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
3 ms |
352 KB |
Output is correct |
3 |
Correct |
5 ms |
592 KB |
Output is correct |
4 |
Correct |
10 ms |
868 KB |
Output is correct |
5 |
Correct |
20 ms |
1348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
352 KB |
Output is correct |
7 |
Correct |
5 ms |
592 KB |
Output is correct |
8 |
Correct |
10 ms |
868 KB |
Output is correct |
9 |
Correct |
20 ms |
1348 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
14 ms |
1112 KB |
Output is correct |
12 |
Correct |
20 ms |
1416 KB |
Output is correct |
13 |
Correct |
19 ms |
1368 KB |
Output is correct |
14 |
Correct |
18 ms |
1352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
352 KB |
Output is correct |
7 |
Correct |
5 ms |
592 KB |
Output is correct |
8 |
Correct |
10 ms |
868 KB |
Output is correct |
9 |
Correct |
20 ms |
1348 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
14 ms |
1112 KB |
Output is correct |
12 |
Correct |
20 ms |
1416 KB |
Output is correct |
13 |
Correct |
19 ms |
1368 KB |
Output is correct |
14 |
Correct |
18 ms |
1352 KB |
Output is correct |
15 |
Correct |
52 ms |
3200 KB |
Output is correct |
16 |
Correct |
52 ms |
3300 KB |
Output is correct |
17 |
Correct |
50 ms |
3264 KB |
Output is correct |
18 |
Correct |
57 ms |
3036 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
352 KB |
Output is correct |
7 |
Correct |
5 ms |
592 KB |
Output is correct |
8 |
Correct |
10 ms |
868 KB |
Output is correct |
9 |
Correct |
20 ms |
1348 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
14 ms |
1112 KB |
Output is correct |
12 |
Correct |
20 ms |
1416 KB |
Output is correct |
13 |
Correct |
19 ms |
1368 KB |
Output is correct |
14 |
Correct |
18 ms |
1352 KB |
Output is correct |
15 |
Correct |
52 ms |
3200 KB |
Output is correct |
16 |
Correct |
52 ms |
3300 KB |
Output is correct |
17 |
Correct |
50 ms |
3264 KB |
Output is correct |
18 |
Correct |
57 ms |
3036 KB |
Output is correct |
19 |
Correct |
54 ms |
3284 KB |
Output is correct |
20 |
Correct |
61 ms |
3292 KB |
Output is correct |
21 |
Correct |
50 ms |
3228 KB |
Output is correct |
22 |
Correct |
52 ms |
3160 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
352 KB |
Output is correct |
7 |
Correct |
5 ms |
592 KB |
Output is correct |
8 |
Correct |
10 ms |
868 KB |
Output is correct |
9 |
Correct |
20 ms |
1348 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
14 ms |
1112 KB |
Output is correct |
12 |
Correct |
20 ms |
1416 KB |
Output is correct |
13 |
Correct |
19 ms |
1368 KB |
Output is correct |
14 |
Correct |
18 ms |
1352 KB |
Output is correct |
15 |
Correct |
52 ms |
3200 KB |
Output is correct |
16 |
Correct |
52 ms |
3300 KB |
Output is correct |
17 |
Correct |
50 ms |
3264 KB |
Output is correct |
18 |
Correct |
57 ms |
3036 KB |
Output is correct |
19 |
Correct |
54 ms |
3284 KB |
Output is correct |
20 |
Correct |
61 ms |
3292 KB |
Output is correct |
21 |
Correct |
50 ms |
3228 KB |
Output is correct |
22 |
Correct |
52 ms |
3160 KB |
Output is correct |
23 |
Correct |
63 ms |
3416 KB |
Output is correct |
24 |
Correct |
57 ms |
3424 KB |
Output is correct |
25 |
Correct |
59 ms |
3288 KB |
Output is correct |
26 |
Correct |
50 ms |
3200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
352 KB |
Output is correct |
7 |
Correct |
5 ms |
592 KB |
Output is correct |
8 |
Correct |
10 ms |
868 KB |
Output is correct |
9 |
Correct |
20 ms |
1348 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
14 ms |
1112 KB |
Output is correct |
12 |
Correct |
20 ms |
1416 KB |
Output is correct |
13 |
Correct |
19 ms |
1368 KB |
Output is correct |
14 |
Correct |
18 ms |
1352 KB |
Output is correct |
15 |
Correct |
52 ms |
3200 KB |
Output is correct |
16 |
Correct |
52 ms |
3300 KB |
Output is correct |
17 |
Correct |
50 ms |
3264 KB |
Output is correct |
18 |
Correct |
57 ms |
3036 KB |
Output is correct |
19 |
Correct |
54 ms |
3284 KB |
Output is correct |
20 |
Correct |
61 ms |
3292 KB |
Output is correct |
21 |
Correct |
50 ms |
3228 KB |
Output is correct |
22 |
Correct |
52 ms |
3160 KB |
Output is correct |
23 |
Correct |
63 ms |
3416 KB |
Output is correct |
24 |
Correct |
57 ms |
3424 KB |
Output is correct |
25 |
Correct |
59 ms |
3288 KB |
Output is correct |
26 |
Correct |
50 ms |
3200 KB |
Output is correct |
27 |
Correct |
56 ms |
3492 KB |
Output is correct |
28 |
Correct |
56 ms |
3504 KB |
Output is correct |
29 |
Correct |
54 ms |
3444 KB |
Output is correct |
30 |
Correct |
52 ms |
3208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
352 KB |
Output is correct |
7 |
Correct |
5 ms |
592 KB |
Output is correct |
8 |
Correct |
10 ms |
868 KB |
Output is correct |
9 |
Correct |
20 ms |
1348 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
14 ms |
1112 KB |
Output is correct |
12 |
Correct |
20 ms |
1416 KB |
Output is correct |
13 |
Correct |
19 ms |
1368 KB |
Output is correct |
14 |
Correct |
18 ms |
1352 KB |
Output is correct |
15 |
Correct |
52 ms |
3200 KB |
Output is correct |
16 |
Correct |
52 ms |
3300 KB |
Output is correct |
17 |
Correct |
50 ms |
3264 KB |
Output is correct |
18 |
Correct |
57 ms |
3036 KB |
Output is correct |
19 |
Correct |
54 ms |
3284 KB |
Output is correct |
20 |
Correct |
61 ms |
3292 KB |
Output is correct |
21 |
Correct |
50 ms |
3228 KB |
Output is correct |
22 |
Correct |
52 ms |
3160 KB |
Output is correct |
23 |
Correct |
63 ms |
3416 KB |
Output is correct |
24 |
Correct |
57 ms |
3424 KB |
Output is correct |
25 |
Correct |
59 ms |
3288 KB |
Output is correct |
26 |
Correct |
50 ms |
3200 KB |
Output is correct |
27 |
Correct |
56 ms |
3492 KB |
Output is correct |
28 |
Correct |
56 ms |
3504 KB |
Output is correct |
29 |
Correct |
54 ms |
3444 KB |
Output is correct |
30 |
Correct |
52 ms |
3208 KB |
Output is correct |
31 |
Correct |
57 ms |
3512 KB |
Output is correct |
32 |
Correct |
61 ms |
3532 KB |
Output is correct |
33 |
Correct |
55 ms |
3412 KB |
Output is correct |
34 |
Correct |
54 ms |
3348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
336 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
336 KB |
Output is correct |
6 |
Correct |
3 ms |
352 KB |
Output is correct |
7 |
Correct |
5 ms |
592 KB |
Output is correct |
8 |
Correct |
10 ms |
868 KB |
Output is correct |
9 |
Correct |
20 ms |
1348 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
14 ms |
1112 KB |
Output is correct |
12 |
Correct |
20 ms |
1416 KB |
Output is correct |
13 |
Correct |
19 ms |
1368 KB |
Output is correct |
14 |
Correct |
18 ms |
1352 KB |
Output is correct |
15 |
Correct |
52 ms |
3200 KB |
Output is correct |
16 |
Correct |
52 ms |
3300 KB |
Output is correct |
17 |
Correct |
50 ms |
3264 KB |
Output is correct |
18 |
Correct |
57 ms |
3036 KB |
Output is correct |
19 |
Correct |
54 ms |
3284 KB |
Output is correct |
20 |
Correct |
61 ms |
3292 KB |
Output is correct |
21 |
Correct |
50 ms |
3228 KB |
Output is correct |
22 |
Correct |
52 ms |
3160 KB |
Output is correct |
23 |
Correct |
63 ms |
3416 KB |
Output is correct |
24 |
Correct |
57 ms |
3424 KB |
Output is correct |
25 |
Correct |
59 ms |
3288 KB |
Output is correct |
26 |
Correct |
50 ms |
3200 KB |
Output is correct |
27 |
Correct |
56 ms |
3492 KB |
Output is correct |
28 |
Correct |
56 ms |
3504 KB |
Output is correct |
29 |
Correct |
54 ms |
3444 KB |
Output is correct |
30 |
Correct |
52 ms |
3208 KB |
Output is correct |
31 |
Correct |
57 ms |
3512 KB |
Output is correct |
32 |
Correct |
61 ms |
3532 KB |
Output is correct |
33 |
Correct |
55 ms |
3412 KB |
Output is correct |
34 |
Correct |
54 ms |
3348 KB |
Output is correct |
35 |
Incorrect |
62 ms |
3576 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |