#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{
int mid;
vector<int>vv[2];
if(l>ll){
mid=l+round(0.37*(r-l));
REP(i,l,mid)qr(v[0][i]);
}else{
mid=l+round(0.63*(r-l));
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:38:3: note: in expansion of macro 'REP'
REP(i,0,vec.size()){
^~~
minerals.cpp:40:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(vv[1].size()==mid-l)vv[0].pb(t);
~~~~~~~~~~~~^~~~~~~
minerals.cpp:41: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 |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
6 ms |
504 KB |
Output is correct |
4 |
Correct |
10 ms |
632 KB |
Output is correct |
5 |
Correct |
18 ms |
1028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Correct |
10 ms |
632 KB |
Output is correct |
9 |
Correct |
18 ms |
1028 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 |
17 ms |
1060 KB |
Output is correct |
14 |
Correct |
17 ms |
1028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Correct |
10 ms |
632 KB |
Output is correct |
9 |
Correct |
18 ms |
1028 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 |
17 ms |
1060 KB |
Output is correct |
14 |
Correct |
17 ms |
1028 KB |
Output is correct |
15 |
Correct |
50 ms |
2320 KB |
Output is correct |
16 |
Correct |
49 ms |
2292 KB |
Output is correct |
17 |
Correct |
44 ms |
2380 KB |
Output is correct |
18 |
Correct |
43 ms |
2096 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Correct |
10 ms |
632 KB |
Output is correct |
9 |
Correct |
18 ms |
1028 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 |
17 ms |
1060 KB |
Output is correct |
14 |
Correct |
17 ms |
1028 KB |
Output is correct |
15 |
Correct |
50 ms |
2320 KB |
Output is correct |
16 |
Correct |
49 ms |
2292 KB |
Output is correct |
17 |
Correct |
44 ms |
2380 KB |
Output is correct |
18 |
Correct |
43 ms |
2096 KB |
Output is correct |
19 |
Correct |
50 ms |
2288 KB |
Output is correct |
20 |
Correct |
51 ms |
2292 KB |
Output is correct |
21 |
Correct |
45 ms |
2208 KB |
Output is correct |
22 |
Correct |
44 ms |
2096 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Correct |
10 ms |
632 KB |
Output is correct |
9 |
Correct |
18 ms |
1028 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 |
17 ms |
1060 KB |
Output is correct |
14 |
Correct |
17 ms |
1028 KB |
Output is correct |
15 |
Correct |
50 ms |
2320 KB |
Output is correct |
16 |
Correct |
49 ms |
2292 KB |
Output is correct |
17 |
Correct |
44 ms |
2380 KB |
Output is correct |
18 |
Correct |
43 ms |
2096 KB |
Output is correct |
19 |
Correct |
50 ms |
2288 KB |
Output is correct |
20 |
Correct |
51 ms |
2292 KB |
Output is correct |
21 |
Correct |
45 ms |
2208 KB |
Output is correct |
22 |
Correct |
44 ms |
2096 KB |
Output is correct |
23 |
Correct |
52 ms |
2292 KB |
Output is correct |
24 |
Correct |
52 ms |
2472 KB |
Output is correct |
25 |
Correct |
46 ms |
2308 KB |
Output is correct |
26 |
Correct |
45 ms |
2184 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Correct |
10 ms |
632 KB |
Output is correct |
9 |
Correct |
18 ms |
1028 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 |
17 ms |
1060 KB |
Output is correct |
14 |
Correct |
17 ms |
1028 KB |
Output is correct |
15 |
Correct |
50 ms |
2320 KB |
Output is correct |
16 |
Correct |
49 ms |
2292 KB |
Output is correct |
17 |
Correct |
44 ms |
2380 KB |
Output is correct |
18 |
Correct |
43 ms |
2096 KB |
Output is correct |
19 |
Correct |
50 ms |
2288 KB |
Output is correct |
20 |
Correct |
51 ms |
2292 KB |
Output is correct |
21 |
Correct |
45 ms |
2208 KB |
Output is correct |
22 |
Correct |
44 ms |
2096 KB |
Output is correct |
23 |
Correct |
52 ms |
2292 KB |
Output is correct |
24 |
Correct |
52 ms |
2472 KB |
Output is correct |
25 |
Correct |
46 ms |
2308 KB |
Output is correct |
26 |
Correct |
45 ms |
2184 KB |
Output is correct |
27 |
Correct |
53 ms |
2424 KB |
Output is correct |
28 |
Correct |
54 ms |
2416 KB |
Output is correct |
29 |
Correct |
47 ms |
2336 KB |
Output is correct |
30 |
Correct |
46 ms |
2204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Correct |
10 ms |
632 KB |
Output is correct |
9 |
Correct |
18 ms |
1028 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 |
17 ms |
1060 KB |
Output is correct |
14 |
Correct |
17 ms |
1028 KB |
Output is correct |
15 |
Correct |
50 ms |
2320 KB |
Output is correct |
16 |
Correct |
49 ms |
2292 KB |
Output is correct |
17 |
Correct |
44 ms |
2380 KB |
Output is correct |
18 |
Correct |
43 ms |
2096 KB |
Output is correct |
19 |
Correct |
50 ms |
2288 KB |
Output is correct |
20 |
Correct |
51 ms |
2292 KB |
Output is correct |
21 |
Correct |
45 ms |
2208 KB |
Output is correct |
22 |
Correct |
44 ms |
2096 KB |
Output is correct |
23 |
Correct |
52 ms |
2292 KB |
Output is correct |
24 |
Correct |
52 ms |
2472 KB |
Output is correct |
25 |
Correct |
46 ms |
2308 KB |
Output is correct |
26 |
Correct |
45 ms |
2184 KB |
Output is correct |
27 |
Correct |
53 ms |
2424 KB |
Output is correct |
28 |
Correct |
54 ms |
2416 KB |
Output is correct |
29 |
Correct |
47 ms |
2336 KB |
Output is correct |
30 |
Correct |
46 ms |
2204 KB |
Output is correct |
31 |
Correct |
55 ms |
2468 KB |
Output is correct |
32 |
Correct |
55 ms |
2420 KB |
Output is correct |
33 |
Correct |
49 ms |
2452 KB |
Output is correct |
34 |
Correct |
47 ms |
2200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
380 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
3 ms |
376 KB |
Output is correct |
6 |
Correct |
4 ms |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
504 KB |
Output is correct |
8 |
Correct |
10 ms |
632 KB |
Output is correct |
9 |
Correct |
18 ms |
1028 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 |
17 ms |
1060 KB |
Output is correct |
14 |
Correct |
17 ms |
1028 KB |
Output is correct |
15 |
Correct |
50 ms |
2320 KB |
Output is correct |
16 |
Correct |
49 ms |
2292 KB |
Output is correct |
17 |
Correct |
44 ms |
2380 KB |
Output is correct |
18 |
Correct |
43 ms |
2096 KB |
Output is correct |
19 |
Correct |
50 ms |
2288 KB |
Output is correct |
20 |
Correct |
51 ms |
2292 KB |
Output is correct |
21 |
Correct |
45 ms |
2208 KB |
Output is correct |
22 |
Correct |
44 ms |
2096 KB |
Output is correct |
23 |
Correct |
52 ms |
2292 KB |
Output is correct |
24 |
Correct |
52 ms |
2472 KB |
Output is correct |
25 |
Correct |
46 ms |
2308 KB |
Output is correct |
26 |
Correct |
45 ms |
2184 KB |
Output is correct |
27 |
Correct |
53 ms |
2424 KB |
Output is correct |
28 |
Correct |
54 ms |
2416 KB |
Output is correct |
29 |
Correct |
47 ms |
2336 KB |
Output is correct |
30 |
Correct |
46 ms |
2204 KB |
Output is correct |
31 |
Correct |
55 ms |
2468 KB |
Output is correct |
32 |
Correct |
55 ms |
2420 KB |
Output is correct |
33 |
Correct |
49 ms |
2452 KB |
Output is correct |
34 |
Correct |
47 ms |
2200 KB |
Output is correct |
35 |
Correct |
56 ms |
2524 KB |
Output is correct |
36 |
Correct |
56 ms |
2548 KB |
Output is correct |
37 |
Correct |
50 ms |
2332 KB |
Output is correct |
38 |
Correct |
49 ms |
2328 KB |
Output is correct |