#include "minerals.h"
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define REP(i,j,k) for(int i=(j);i<(k);++i)
#define pb push_back
// #define __debug
#ifdef __debug
#define pr(...) cerr<<__VA_ARGS__
#define ar(a,s,t) {rep(zy,s,t)pr(a[zy]<<' ');pr(endl);}
#else
#define pr(...) (void)0
#define ar(...) (void)0
#endif
//
int ls=0,ll=0;
vector<int>v[2];
int qr(int x){
int t=Query(x+1);
swap(t,ls);
return ls==t;
}
void sol(int l,int r,vector<int>&vec){
if(l+1==r)Answer(v[0][l]+1,vec[0]+1);
else{
double ratio=0.5;
int mid=round(l*ratio+r*(1-ratio));
vector<int>vv[2];
if(l>ll)REP(i,l,mid)qr(v[0][i]);
else REP(i,mid,r)qr(v[0][i]);
ll=l;
REP(i,0,vec.size()){
int t=vec[i];
if(vv[1].size()==mid-l)vv[0].pb(t);
else if(vv[0].size()==r-mid)vv[1].pb(t);
else vv[qr(t)].pb(t);
}
sol(l,mid,vv[1]);
sol(mid,r,vv[0]);
}
vector<int>().swap(vec);
}
void Solve(int n){
REP(i,0,2*n)v[qr(i)].pb(i);
random_shuffle(v[1].begin(),v[1].end());
sol(0,n,v[1]);
}
Compilation message
minerals.cpp: In function 'void sol(int, int, std::vector<int>&)':
minerals.cpp:5:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define REP(i,j,k) for(int i=(j);i<(k);++i)
^
minerals.cpp:34:3: note: in expansion of macro 'REP'
REP(i,0,vec.size()){
^~~
minerals.cpp:36:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(vv[1].size()==mid-l)vv[0].pb(t);
~~~~~~~~~~~~^~~~~~~
minerals.cpp:37:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
else if(vv[0].size()==r-mid)vv[1].pb(t);
~~~~~~~~~~~~^~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
9 ms |
632 KB |
Output is correct |
5 |
Correct |
17 ms |
1016 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
248 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
504 KB |
Output is correct |
8 |
Correct |
9 ms |
632 KB |
Output is correct |
9 |
Correct |
17 ms |
1016 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
12 ms |
760 KB |
Output is correct |
12 |
Correct |
18 ms |
1144 KB |
Output is correct |
13 |
Correct |
16 ms |
1016 KB |
Output is correct |
14 |
Correct |
16 ms |
936 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
248 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
504 KB |
Output is correct |
8 |
Correct |
9 ms |
632 KB |
Output is correct |
9 |
Correct |
17 ms |
1016 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
12 ms |
760 KB |
Output is correct |
12 |
Correct |
18 ms |
1144 KB |
Output is correct |
13 |
Correct |
16 ms |
1016 KB |
Output is correct |
14 |
Correct |
16 ms |
936 KB |
Output is correct |
15 |
Correct |
48 ms |
2292 KB |
Output is correct |
16 |
Correct |
49 ms |
2300 KB |
Output is correct |
17 |
Correct |
43 ms |
2168 KB |
Output is correct |
18 |
Correct |
42 ms |
2036 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
248 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
504 KB |
Output is correct |
8 |
Correct |
9 ms |
632 KB |
Output is correct |
9 |
Correct |
17 ms |
1016 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
12 ms |
760 KB |
Output is correct |
12 |
Correct |
18 ms |
1144 KB |
Output is correct |
13 |
Correct |
16 ms |
1016 KB |
Output is correct |
14 |
Correct |
16 ms |
936 KB |
Output is correct |
15 |
Correct |
48 ms |
2292 KB |
Output is correct |
16 |
Correct |
49 ms |
2300 KB |
Output is correct |
17 |
Correct |
43 ms |
2168 KB |
Output is correct |
18 |
Correct |
42 ms |
2036 KB |
Output is correct |
19 |
Correct |
52 ms |
2292 KB |
Output is correct |
20 |
Correct |
49 ms |
2296 KB |
Output is correct |
21 |
Correct |
46 ms |
2268 KB |
Output is correct |
22 |
Correct |
43 ms |
2032 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
248 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
504 KB |
Output is correct |
8 |
Correct |
9 ms |
632 KB |
Output is correct |
9 |
Correct |
17 ms |
1016 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
12 ms |
760 KB |
Output is correct |
12 |
Correct |
18 ms |
1144 KB |
Output is correct |
13 |
Correct |
16 ms |
1016 KB |
Output is correct |
14 |
Correct |
16 ms |
936 KB |
Output is correct |
15 |
Correct |
48 ms |
2292 KB |
Output is correct |
16 |
Correct |
49 ms |
2300 KB |
Output is correct |
17 |
Correct |
43 ms |
2168 KB |
Output is correct |
18 |
Correct |
42 ms |
2036 KB |
Output is correct |
19 |
Correct |
52 ms |
2292 KB |
Output is correct |
20 |
Correct |
49 ms |
2296 KB |
Output is correct |
21 |
Correct |
46 ms |
2268 KB |
Output is correct |
22 |
Correct |
43 ms |
2032 KB |
Output is correct |
23 |
Correct |
51 ms |
2384 KB |
Output is correct |
24 |
Correct |
51 ms |
2336 KB |
Output is correct |
25 |
Correct |
45 ms |
2420 KB |
Output is correct |
26 |
Correct |
48 ms |
2128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
248 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
504 KB |
Output is correct |
8 |
Correct |
9 ms |
632 KB |
Output is correct |
9 |
Correct |
17 ms |
1016 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
12 ms |
760 KB |
Output is correct |
12 |
Correct |
18 ms |
1144 KB |
Output is correct |
13 |
Correct |
16 ms |
1016 KB |
Output is correct |
14 |
Correct |
16 ms |
936 KB |
Output is correct |
15 |
Correct |
48 ms |
2292 KB |
Output is correct |
16 |
Correct |
49 ms |
2300 KB |
Output is correct |
17 |
Correct |
43 ms |
2168 KB |
Output is correct |
18 |
Correct |
42 ms |
2036 KB |
Output is correct |
19 |
Correct |
52 ms |
2292 KB |
Output is correct |
20 |
Correct |
49 ms |
2296 KB |
Output is correct |
21 |
Correct |
46 ms |
2268 KB |
Output is correct |
22 |
Correct |
43 ms |
2032 KB |
Output is correct |
23 |
Correct |
51 ms |
2384 KB |
Output is correct |
24 |
Correct |
51 ms |
2336 KB |
Output is correct |
25 |
Correct |
45 ms |
2420 KB |
Output is correct |
26 |
Correct |
48 ms |
2128 KB |
Output is correct |
27 |
Correct |
59 ms |
2364 KB |
Output is correct |
28 |
Correct |
53 ms |
2288 KB |
Output is correct |
29 |
Correct |
47 ms |
2292 KB |
Output is correct |
30 |
Correct |
46 ms |
2196 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
248 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
504 KB |
Output is correct |
8 |
Correct |
9 ms |
632 KB |
Output is correct |
9 |
Correct |
17 ms |
1016 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
12 ms |
760 KB |
Output is correct |
12 |
Correct |
18 ms |
1144 KB |
Output is correct |
13 |
Correct |
16 ms |
1016 KB |
Output is correct |
14 |
Correct |
16 ms |
936 KB |
Output is correct |
15 |
Correct |
48 ms |
2292 KB |
Output is correct |
16 |
Correct |
49 ms |
2300 KB |
Output is correct |
17 |
Correct |
43 ms |
2168 KB |
Output is correct |
18 |
Correct |
42 ms |
2036 KB |
Output is correct |
19 |
Correct |
52 ms |
2292 KB |
Output is correct |
20 |
Correct |
49 ms |
2296 KB |
Output is correct |
21 |
Correct |
46 ms |
2268 KB |
Output is correct |
22 |
Correct |
43 ms |
2032 KB |
Output is correct |
23 |
Correct |
51 ms |
2384 KB |
Output is correct |
24 |
Correct |
51 ms |
2336 KB |
Output is correct |
25 |
Correct |
45 ms |
2420 KB |
Output is correct |
26 |
Correct |
48 ms |
2128 KB |
Output is correct |
27 |
Correct |
59 ms |
2364 KB |
Output is correct |
28 |
Correct |
53 ms |
2288 KB |
Output is correct |
29 |
Correct |
47 ms |
2292 KB |
Output is correct |
30 |
Correct |
46 ms |
2196 KB |
Output is correct |
31 |
Correct |
54 ms |
2440 KB |
Output is correct |
32 |
Correct |
53 ms |
2304 KB |
Output is correct |
33 |
Correct |
48 ms |
2424 KB |
Output is correct |
34 |
Correct |
46 ms |
2244 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
3 ms |
248 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
504 KB |
Output is correct |
8 |
Correct |
9 ms |
632 KB |
Output is correct |
9 |
Correct |
17 ms |
1016 KB |
Output is correct |
10 |
Correct |
3 ms |
376 KB |
Output is correct |
11 |
Correct |
12 ms |
760 KB |
Output is correct |
12 |
Correct |
18 ms |
1144 KB |
Output is correct |
13 |
Correct |
16 ms |
1016 KB |
Output is correct |
14 |
Correct |
16 ms |
936 KB |
Output is correct |
15 |
Correct |
48 ms |
2292 KB |
Output is correct |
16 |
Correct |
49 ms |
2300 KB |
Output is correct |
17 |
Correct |
43 ms |
2168 KB |
Output is correct |
18 |
Correct |
42 ms |
2036 KB |
Output is correct |
19 |
Correct |
52 ms |
2292 KB |
Output is correct |
20 |
Correct |
49 ms |
2296 KB |
Output is correct |
21 |
Correct |
46 ms |
2268 KB |
Output is correct |
22 |
Correct |
43 ms |
2032 KB |
Output is correct |
23 |
Correct |
51 ms |
2384 KB |
Output is correct |
24 |
Correct |
51 ms |
2336 KB |
Output is correct |
25 |
Correct |
45 ms |
2420 KB |
Output is correct |
26 |
Correct |
48 ms |
2128 KB |
Output is correct |
27 |
Correct |
59 ms |
2364 KB |
Output is correct |
28 |
Correct |
53 ms |
2288 KB |
Output is correct |
29 |
Correct |
47 ms |
2292 KB |
Output is correct |
30 |
Correct |
46 ms |
2196 KB |
Output is correct |
31 |
Correct |
54 ms |
2440 KB |
Output is correct |
32 |
Correct |
53 ms |
2304 KB |
Output is correct |
33 |
Correct |
48 ms |
2424 KB |
Output is correct |
34 |
Correct |
46 ms |
2244 KB |
Output is correct |
35 |
Incorrect |
54 ms |
2436 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |