#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define INF 1000000000//00000000
#define modulo 1000000007
#define mod 998244353
//#define int long long int
using namespace std;
#include "minerals.h"
int last = 0;
unordered_set<int> S;
void add(int x){
if(S.count(x))S.erase(x);
else S.insert(x);
}
void extract(vector<int>& A, vector<int>& B, vector<int>& X, vector<int>& Y){
int n = sz(A), m = sz(B);
int b = 0;
random_shuffle(all(B));
for(int i = 0; i < m; i++){
int v;
if(b == sz(A)) v = INF;
else v = Query(B[i]), add(B[i]);
if(v == last){
X.pb(B[i]);
b++;
}
else Y.pb(B[i]);
if(v != INF)
last = v;
}
}
void divide(vector<int>& A, vector<int>& B){
int n = A.size();
if(n == 1){
Answer(A[0], B[0]);
return;
}
random_shuffle(all(B));
vector<int> X, Y;
vector<int> tempA, tempB;
for(int i = 0; i <= 0.36 * n; i++)tempA.pb(A[i]);
for(int i = 0.36 * n + 1; i < n; i++)tempB.pb(A[i]);
if(!(S.count(tempA[0]) ^ S.count(tempB[0]))){
if(tempB.size() > tempA.size()) swap(tempA, tempB);
for(int i = 0; i < tempB.size(); i++) last = Query(tempB[i]), add(tempB[i]);
}
if(S.count(tempB[0])){
swap(tempA, tempB);
}
extract(tempA, B, X, Y);
divide(tempA, X);
divide(tempB, Y);
}
void Solve(int N) {
vector<int> A, B;
vector<int> arr;
for(int i = 1; i <= 2 * N; i++)arr.pb(i);
srand(time(NULL));
random_shuffle(all(arr));
for(auto i : arr){
int q;
if(last == N) q = last;
else q = Query(i);
S.insert(i);
if(last == q){
B.pb(i);
}
else{
A.pb(i);
}
last = q;
}
divide(A, B);
}
Compilation message
minerals.cpp: In function 'void extract(std::vector<int>&, std::vector<int>&, std::vector<int>&, std::vector<int>&)':
minerals.cpp:24:11: warning: unused variable 'n' [-Wunused-variable]
int n = sz(A), m = sz(B);
^
minerals.cpp: In function 'void divide(std::vector<int>&, std::vector<int>&)':
minerals.cpp:54:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < tempB.size(); i++) last = Query(tempB[i]), add(tempB[i]);
~~^~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
504 KB |
Output is correct |
2 |
Correct |
10 ms |
504 KB |
Output is correct |
3 |
Correct |
16 ms |
888 KB |
Output is correct |
4 |
Correct |
31 ms |
1528 KB |
Output is correct |
5 |
Correct |
56 ms |
2524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
7 ms |
504 KB |
Output is correct |
6 |
Correct |
10 ms |
504 KB |
Output is correct |
7 |
Correct |
16 ms |
888 KB |
Output is correct |
8 |
Correct |
31 ms |
1528 KB |
Output is correct |
9 |
Correct |
56 ms |
2524 KB |
Output is correct |
10 |
Correct |
7 ms |
504 KB |
Output is correct |
11 |
Correct |
45 ms |
1656 KB |
Output is correct |
12 |
Correct |
59 ms |
2600 KB |
Output is correct |
13 |
Correct |
59 ms |
2504 KB |
Output is correct |
14 |
Correct |
59 ms |
2472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
7 ms |
504 KB |
Output is correct |
6 |
Correct |
10 ms |
504 KB |
Output is correct |
7 |
Correct |
16 ms |
888 KB |
Output is correct |
8 |
Correct |
31 ms |
1528 KB |
Output is correct |
9 |
Correct |
56 ms |
2524 KB |
Output is correct |
10 |
Correct |
7 ms |
504 KB |
Output is correct |
11 |
Correct |
45 ms |
1656 KB |
Output is correct |
12 |
Correct |
59 ms |
2600 KB |
Output is correct |
13 |
Correct |
59 ms |
2504 KB |
Output is correct |
14 |
Correct |
59 ms |
2472 KB |
Output is correct |
15 |
Correct |
161 ms |
5840 KB |
Output is correct |
16 |
Correct |
182 ms |
5708 KB |
Output is correct |
17 |
Correct |
173 ms |
5968 KB |
Output is correct |
18 |
Correct |
190 ms |
5712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
7 ms |
504 KB |
Output is correct |
6 |
Correct |
10 ms |
504 KB |
Output is correct |
7 |
Correct |
16 ms |
888 KB |
Output is correct |
8 |
Correct |
31 ms |
1528 KB |
Output is correct |
9 |
Correct |
56 ms |
2524 KB |
Output is correct |
10 |
Correct |
7 ms |
504 KB |
Output is correct |
11 |
Correct |
45 ms |
1656 KB |
Output is correct |
12 |
Correct |
59 ms |
2600 KB |
Output is correct |
13 |
Correct |
59 ms |
2504 KB |
Output is correct |
14 |
Correct |
59 ms |
2472 KB |
Output is correct |
15 |
Correct |
161 ms |
5840 KB |
Output is correct |
16 |
Correct |
182 ms |
5708 KB |
Output is correct |
17 |
Correct |
173 ms |
5968 KB |
Output is correct |
18 |
Correct |
190 ms |
5712 KB |
Output is correct |
19 |
Correct |
194 ms |
5920 KB |
Output is correct |
20 |
Correct |
182 ms |
5836 KB |
Output is correct |
21 |
Correct |
178 ms |
5968 KB |
Output is correct |
22 |
Correct |
176 ms |
5712 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
7 ms |
504 KB |
Output is correct |
6 |
Correct |
10 ms |
504 KB |
Output is correct |
7 |
Correct |
16 ms |
888 KB |
Output is correct |
8 |
Correct |
31 ms |
1528 KB |
Output is correct |
9 |
Correct |
56 ms |
2524 KB |
Output is correct |
10 |
Correct |
7 ms |
504 KB |
Output is correct |
11 |
Correct |
45 ms |
1656 KB |
Output is correct |
12 |
Correct |
59 ms |
2600 KB |
Output is correct |
13 |
Correct |
59 ms |
2504 KB |
Output is correct |
14 |
Correct |
59 ms |
2472 KB |
Output is correct |
15 |
Correct |
161 ms |
5840 KB |
Output is correct |
16 |
Correct |
182 ms |
5708 KB |
Output is correct |
17 |
Correct |
173 ms |
5968 KB |
Output is correct |
18 |
Correct |
190 ms |
5712 KB |
Output is correct |
19 |
Correct |
194 ms |
5920 KB |
Output is correct |
20 |
Correct |
182 ms |
5836 KB |
Output is correct |
21 |
Correct |
178 ms |
5968 KB |
Output is correct |
22 |
Correct |
176 ms |
5712 KB |
Output is correct |
23 |
Correct |
186 ms |
6020 KB |
Output is correct |
24 |
Correct |
188 ms |
5964 KB |
Output is correct |
25 |
Correct |
173 ms |
5972 KB |
Output is correct |
26 |
Correct |
176 ms |
5836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
7 ms |
504 KB |
Output is correct |
6 |
Correct |
10 ms |
504 KB |
Output is correct |
7 |
Correct |
16 ms |
888 KB |
Output is correct |
8 |
Correct |
31 ms |
1528 KB |
Output is correct |
9 |
Correct |
56 ms |
2524 KB |
Output is correct |
10 |
Correct |
7 ms |
504 KB |
Output is correct |
11 |
Correct |
45 ms |
1656 KB |
Output is correct |
12 |
Correct |
59 ms |
2600 KB |
Output is correct |
13 |
Correct |
59 ms |
2504 KB |
Output is correct |
14 |
Correct |
59 ms |
2472 KB |
Output is correct |
15 |
Correct |
161 ms |
5840 KB |
Output is correct |
16 |
Correct |
182 ms |
5708 KB |
Output is correct |
17 |
Correct |
173 ms |
5968 KB |
Output is correct |
18 |
Correct |
190 ms |
5712 KB |
Output is correct |
19 |
Correct |
194 ms |
5920 KB |
Output is correct |
20 |
Correct |
182 ms |
5836 KB |
Output is correct |
21 |
Correct |
178 ms |
5968 KB |
Output is correct |
22 |
Correct |
176 ms |
5712 KB |
Output is correct |
23 |
Correct |
186 ms |
6020 KB |
Output is correct |
24 |
Correct |
188 ms |
5964 KB |
Output is correct |
25 |
Correct |
173 ms |
5972 KB |
Output is correct |
26 |
Correct |
176 ms |
5836 KB |
Output is correct |
27 |
Correct |
194 ms |
6108 KB |
Output is correct |
28 |
Correct |
186 ms |
6188 KB |
Output is correct |
29 |
Correct |
185 ms |
6096 KB |
Output is correct |
30 |
Correct |
181 ms |
5944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
7 ms |
504 KB |
Output is correct |
6 |
Correct |
10 ms |
504 KB |
Output is correct |
7 |
Correct |
16 ms |
888 KB |
Output is correct |
8 |
Correct |
31 ms |
1528 KB |
Output is correct |
9 |
Correct |
56 ms |
2524 KB |
Output is correct |
10 |
Correct |
7 ms |
504 KB |
Output is correct |
11 |
Correct |
45 ms |
1656 KB |
Output is correct |
12 |
Correct |
59 ms |
2600 KB |
Output is correct |
13 |
Correct |
59 ms |
2504 KB |
Output is correct |
14 |
Correct |
59 ms |
2472 KB |
Output is correct |
15 |
Correct |
161 ms |
5840 KB |
Output is correct |
16 |
Correct |
182 ms |
5708 KB |
Output is correct |
17 |
Correct |
173 ms |
5968 KB |
Output is correct |
18 |
Correct |
190 ms |
5712 KB |
Output is correct |
19 |
Correct |
194 ms |
5920 KB |
Output is correct |
20 |
Correct |
182 ms |
5836 KB |
Output is correct |
21 |
Correct |
178 ms |
5968 KB |
Output is correct |
22 |
Correct |
176 ms |
5712 KB |
Output is correct |
23 |
Correct |
186 ms |
6020 KB |
Output is correct |
24 |
Correct |
188 ms |
5964 KB |
Output is correct |
25 |
Correct |
173 ms |
5972 KB |
Output is correct |
26 |
Correct |
176 ms |
5836 KB |
Output is correct |
27 |
Correct |
194 ms |
6108 KB |
Output is correct |
28 |
Correct |
186 ms |
6188 KB |
Output is correct |
29 |
Correct |
185 ms |
6096 KB |
Output is correct |
30 |
Correct |
181 ms |
5944 KB |
Output is correct |
31 |
Correct |
197 ms |
6272 KB |
Output is correct |
32 |
Correct |
189 ms |
6276 KB |
Output is correct |
33 |
Correct |
191 ms |
6224 KB |
Output is correct |
34 |
Correct |
178 ms |
6096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
7 ms |
504 KB |
Output is correct |
6 |
Correct |
10 ms |
504 KB |
Output is correct |
7 |
Correct |
16 ms |
888 KB |
Output is correct |
8 |
Correct |
31 ms |
1528 KB |
Output is correct |
9 |
Correct |
56 ms |
2524 KB |
Output is correct |
10 |
Correct |
7 ms |
504 KB |
Output is correct |
11 |
Correct |
45 ms |
1656 KB |
Output is correct |
12 |
Correct |
59 ms |
2600 KB |
Output is correct |
13 |
Correct |
59 ms |
2504 KB |
Output is correct |
14 |
Correct |
59 ms |
2472 KB |
Output is correct |
15 |
Correct |
161 ms |
5840 KB |
Output is correct |
16 |
Correct |
182 ms |
5708 KB |
Output is correct |
17 |
Correct |
173 ms |
5968 KB |
Output is correct |
18 |
Correct |
190 ms |
5712 KB |
Output is correct |
19 |
Correct |
194 ms |
5920 KB |
Output is correct |
20 |
Correct |
182 ms |
5836 KB |
Output is correct |
21 |
Correct |
178 ms |
5968 KB |
Output is correct |
22 |
Correct |
176 ms |
5712 KB |
Output is correct |
23 |
Correct |
186 ms |
6020 KB |
Output is correct |
24 |
Correct |
188 ms |
5964 KB |
Output is correct |
25 |
Correct |
173 ms |
5972 KB |
Output is correct |
26 |
Correct |
176 ms |
5836 KB |
Output is correct |
27 |
Correct |
194 ms |
6108 KB |
Output is correct |
28 |
Correct |
186 ms |
6188 KB |
Output is correct |
29 |
Correct |
185 ms |
6096 KB |
Output is correct |
30 |
Correct |
181 ms |
5944 KB |
Output is correct |
31 |
Correct |
197 ms |
6272 KB |
Output is correct |
32 |
Correct |
189 ms |
6276 KB |
Output is correct |
33 |
Correct |
191 ms |
6224 KB |
Output is correct |
34 |
Correct |
178 ms |
6096 KB |
Output is correct |
35 |
Incorrect |
177 ms |
6292 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |