#include "minerals.h"
#include <bits/stdc++.h>
#pragma GCC optimize ("O2,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef vector<int> vi;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define SZ(x) ((int)x.size())
const int inf=1000000010;
const ll INF=1000000000000001000LL;
const int mod=1000000007;
const int MAXN=100010, LOG=20;
int n, m, k, u, v, x, y, a, b, t, ans;
int mark[MAXN], shit;
set<int> On;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Ask(int x){
// cerr<<"Ask "<<x<<"\n";
auto it=On.find(x);
if (it==On.end()) On.insert(x);
else On.erase(it);
return ans=Query(x);
}
bool IsOn(int x){ return On.find(x)!=On.end();}
void Set(vi vec){
shit++;
for (int x:vec){
mark[x]=shit;
if (!IsOn(x)) Ask(x);
}
vi rem;
for (int x:On) if (mark[x]!=shit) rem.pb(x);
for (int x:rem) Ask(x);
}
void divide(vi X, vi Y){
assert(SZ(X)==SZ(Y));
if (SZ(X)==1){
Answer(X[0], Y[0]);
return ;
}
int sz=SZ(X), mid=sz/2;
// shuffle(all(X), rng);
vi X1, X2, Y1, Y2;
for (int i=0; i<sz; i++){
if (i<mid) X1.pb(X[i]);
else X2.pb(X[i]);
}
// Set(X1);
for (int x:X1) if (!IsOn(x)) Ask(x);
for (int x:X2) if (IsOn(x)) Ask(x);
for (int y:Y) if (IsOn(x)) Ask(x);
for (int y:Y){
if (SZ(Y1)==mid) Y2.pb(y);
else if (SZ(Y2)==sz-mid) Y1.pb(y);
else{
int last=ans;
if (Ask(y)==last) Y1.pb(y);
else Y2.pb(y);
}
}
divide(X1, Y1);
divide(X2, Y2);
}
void Solve(int _n){
n=_n;
vi X, Y;
for (int i=1; i<=2*n; i++){
int last=ans;
if (Ask(i)==last) Y.pb(i);
else X.pb(i);
}
divide(X, Y);
}
Compilation message
minerals.cpp: In function 'void divide(vi, vi)':
minerals.cpp:66:11: warning: unused variable 'y' [-Wunused-variable]
66 | for (int y:Y) if (IsOn(x)) Ask(x);
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
456 KB |
Output is correct |
2 |
Correct |
8 ms |
584 KB |
Output is correct |
3 |
Correct |
18 ms |
840 KB |
Output is correct |
4 |
Correct |
41 ms |
1352 KB |
Output is correct |
5 |
Correct |
86 ms |
2432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
4 ms |
456 KB |
Output is correct |
6 |
Correct |
8 ms |
584 KB |
Output is correct |
7 |
Correct |
18 ms |
840 KB |
Output is correct |
8 |
Correct |
41 ms |
1352 KB |
Output is correct |
9 |
Correct |
86 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
464 KB |
Output is correct |
11 |
Correct |
54 ms |
1716 KB |
Output is correct |
12 |
Correct |
87 ms |
2404 KB |
Output is correct |
13 |
Correct |
66 ms |
2624 KB |
Output is correct |
14 |
Correct |
64 ms |
2440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
4 ms |
456 KB |
Output is correct |
6 |
Correct |
8 ms |
584 KB |
Output is correct |
7 |
Correct |
18 ms |
840 KB |
Output is correct |
8 |
Correct |
41 ms |
1352 KB |
Output is correct |
9 |
Correct |
86 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
464 KB |
Output is correct |
11 |
Correct |
54 ms |
1716 KB |
Output is correct |
12 |
Correct |
87 ms |
2404 KB |
Output is correct |
13 |
Correct |
66 ms |
2624 KB |
Output is correct |
14 |
Correct |
64 ms |
2440 KB |
Output is correct |
15 |
Correct |
269 ms |
5904 KB |
Output is correct |
16 |
Correct |
269 ms |
5944 KB |
Output is correct |
17 |
Correct |
193 ms |
6144 KB |
Output is correct |
18 |
Correct |
176 ms |
5776 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
4 ms |
456 KB |
Output is correct |
6 |
Correct |
8 ms |
584 KB |
Output is correct |
7 |
Correct |
18 ms |
840 KB |
Output is correct |
8 |
Correct |
41 ms |
1352 KB |
Output is correct |
9 |
Correct |
86 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
464 KB |
Output is correct |
11 |
Correct |
54 ms |
1716 KB |
Output is correct |
12 |
Correct |
87 ms |
2404 KB |
Output is correct |
13 |
Correct |
66 ms |
2624 KB |
Output is correct |
14 |
Correct |
64 ms |
2440 KB |
Output is correct |
15 |
Correct |
269 ms |
5904 KB |
Output is correct |
16 |
Correct |
269 ms |
5944 KB |
Output is correct |
17 |
Correct |
193 ms |
6144 KB |
Output is correct |
18 |
Correct |
176 ms |
5776 KB |
Output is correct |
19 |
Correct |
331 ms |
6104 KB |
Output is correct |
20 |
Correct |
277 ms |
6008 KB |
Output is correct |
21 |
Correct |
197 ms |
6412 KB |
Output is correct |
22 |
Correct |
189 ms |
6012 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
4 ms |
456 KB |
Output is correct |
6 |
Correct |
8 ms |
584 KB |
Output is correct |
7 |
Correct |
18 ms |
840 KB |
Output is correct |
8 |
Correct |
41 ms |
1352 KB |
Output is correct |
9 |
Correct |
86 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
464 KB |
Output is correct |
11 |
Correct |
54 ms |
1716 KB |
Output is correct |
12 |
Correct |
87 ms |
2404 KB |
Output is correct |
13 |
Correct |
66 ms |
2624 KB |
Output is correct |
14 |
Correct |
64 ms |
2440 KB |
Output is correct |
15 |
Correct |
269 ms |
5904 KB |
Output is correct |
16 |
Correct |
269 ms |
5944 KB |
Output is correct |
17 |
Correct |
193 ms |
6144 KB |
Output is correct |
18 |
Correct |
176 ms |
5776 KB |
Output is correct |
19 |
Correct |
331 ms |
6104 KB |
Output is correct |
20 |
Correct |
277 ms |
6008 KB |
Output is correct |
21 |
Correct |
197 ms |
6412 KB |
Output is correct |
22 |
Correct |
189 ms |
6012 KB |
Output is correct |
23 |
Correct |
291 ms |
6240 KB |
Output is correct |
24 |
Correct |
291 ms |
6248 KB |
Output is correct |
25 |
Correct |
200 ms |
6540 KB |
Output is correct |
26 |
Correct |
204 ms |
5964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
4 ms |
456 KB |
Output is correct |
6 |
Correct |
8 ms |
584 KB |
Output is correct |
7 |
Correct |
18 ms |
840 KB |
Output is correct |
8 |
Correct |
41 ms |
1352 KB |
Output is correct |
9 |
Correct |
86 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
464 KB |
Output is correct |
11 |
Correct |
54 ms |
1716 KB |
Output is correct |
12 |
Correct |
87 ms |
2404 KB |
Output is correct |
13 |
Correct |
66 ms |
2624 KB |
Output is correct |
14 |
Correct |
64 ms |
2440 KB |
Output is correct |
15 |
Correct |
269 ms |
5904 KB |
Output is correct |
16 |
Correct |
269 ms |
5944 KB |
Output is correct |
17 |
Correct |
193 ms |
6144 KB |
Output is correct |
18 |
Correct |
176 ms |
5776 KB |
Output is correct |
19 |
Correct |
331 ms |
6104 KB |
Output is correct |
20 |
Correct |
277 ms |
6008 KB |
Output is correct |
21 |
Correct |
197 ms |
6412 KB |
Output is correct |
22 |
Correct |
189 ms |
6012 KB |
Output is correct |
23 |
Correct |
291 ms |
6240 KB |
Output is correct |
24 |
Correct |
291 ms |
6248 KB |
Output is correct |
25 |
Correct |
200 ms |
6540 KB |
Output is correct |
26 |
Correct |
204 ms |
5964 KB |
Output is correct |
27 |
Correct |
301 ms |
6348 KB |
Output is correct |
28 |
Correct |
284 ms |
6368 KB |
Output is correct |
29 |
Correct |
245 ms |
6644 KB |
Output is correct |
30 |
Correct |
201 ms |
6164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
4 ms |
456 KB |
Output is correct |
6 |
Correct |
8 ms |
584 KB |
Output is correct |
7 |
Correct |
18 ms |
840 KB |
Output is correct |
8 |
Correct |
41 ms |
1352 KB |
Output is correct |
9 |
Correct |
86 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
464 KB |
Output is correct |
11 |
Correct |
54 ms |
1716 KB |
Output is correct |
12 |
Correct |
87 ms |
2404 KB |
Output is correct |
13 |
Correct |
66 ms |
2624 KB |
Output is correct |
14 |
Correct |
64 ms |
2440 KB |
Output is correct |
15 |
Correct |
269 ms |
5904 KB |
Output is correct |
16 |
Correct |
269 ms |
5944 KB |
Output is correct |
17 |
Correct |
193 ms |
6144 KB |
Output is correct |
18 |
Correct |
176 ms |
5776 KB |
Output is correct |
19 |
Correct |
331 ms |
6104 KB |
Output is correct |
20 |
Correct |
277 ms |
6008 KB |
Output is correct |
21 |
Correct |
197 ms |
6412 KB |
Output is correct |
22 |
Correct |
189 ms |
6012 KB |
Output is correct |
23 |
Correct |
291 ms |
6240 KB |
Output is correct |
24 |
Correct |
291 ms |
6248 KB |
Output is correct |
25 |
Correct |
200 ms |
6540 KB |
Output is correct |
26 |
Correct |
204 ms |
5964 KB |
Output is correct |
27 |
Correct |
301 ms |
6348 KB |
Output is correct |
28 |
Correct |
284 ms |
6368 KB |
Output is correct |
29 |
Correct |
245 ms |
6644 KB |
Output is correct |
30 |
Correct |
201 ms |
6164 KB |
Output is correct |
31 |
Correct |
314 ms |
6540 KB |
Output is correct |
32 |
Correct |
299 ms |
6536 KB |
Output is correct |
33 |
Correct |
212 ms |
6844 KB |
Output is correct |
34 |
Correct |
204 ms |
6360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
4 ms |
456 KB |
Output is correct |
6 |
Correct |
8 ms |
584 KB |
Output is correct |
7 |
Correct |
18 ms |
840 KB |
Output is correct |
8 |
Correct |
41 ms |
1352 KB |
Output is correct |
9 |
Correct |
86 ms |
2432 KB |
Output is correct |
10 |
Correct |
4 ms |
464 KB |
Output is correct |
11 |
Correct |
54 ms |
1716 KB |
Output is correct |
12 |
Correct |
87 ms |
2404 KB |
Output is correct |
13 |
Correct |
66 ms |
2624 KB |
Output is correct |
14 |
Correct |
64 ms |
2440 KB |
Output is correct |
15 |
Correct |
269 ms |
5904 KB |
Output is correct |
16 |
Correct |
269 ms |
5944 KB |
Output is correct |
17 |
Correct |
193 ms |
6144 KB |
Output is correct |
18 |
Correct |
176 ms |
5776 KB |
Output is correct |
19 |
Correct |
331 ms |
6104 KB |
Output is correct |
20 |
Correct |
277 ms |
6008 KB |
Output is correct |
21 |
Correct |
197 ms |
6412 KB |
Output is correct |
22 |
Correct |
189 ms |
6012 KB |
Output is correct |
23 |
Correct |
291 ms |
6240 KB |
Output is correct |
24 |
Correct |
291 ms |
6248 KB |
Output is correct |
25 |
Correct |
200 ms |
6540 KB |
Output is correct |
26 |
Correct |
204 ms |
5964 KB |
Output is correct |
27 |
Correct |
301 ms |
6348 KB |
Output is correct |
28 |
Correct |
284 ms |
6368 KB |
Output is correct |
29 |
Correct |
245 ms |
6644 KB |
Output is correct |
30 |
Correct |
201 ms |
6164 KB |
Output is correct |
31 |
Correct |
314 ms |
6540 KB |
Output is correct |
32 |
Correct |
299 ms |
6536 KB |
Output is correct |
33 |
Correct |
212 ms |
6844 KB |
Output is correct |
34 |
Correct |
204 ms |
6360 KB |
Output is correct |
35 |
Incorrect |
313 ms |
6544 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |