#include <bits/stdc++.h>
#include "minerals.h"
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long
#define en cin.close();return 0;
#define pb push_back
#define fi first//printf("%lli\n",cur);
#define se second//scanf("%lli",&n);
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2*43005;
int n1, cur;
bool is[N];
int q(int x)
{
is[x]^=1;
return cur=Query(x);
}
void go(vector<int> &a, vector<int> &b)
{
random_shuffle(a.begin(),a.end());
random_shuffle(b.begin(),b.end());
assert(a.size()==b.size());
int n = a.size(), mid = min(n - 1, (int)ceil(0.5*n));
if(n==1)
Answer(a[0],b[0]);
else
{
vector<int> la, ra, lb, rb;
sort(a.begin(),a.end(),[&](int &i, int &j){return (is[i]>is[j]);});
for(int i = 0;i<n;i++)
{
if(i<mid)
{
if(!is[a[i]])//sort in order is[a[i]]>is[a[j]]
q(a[i]);
la.pb(a[i]);
}
else
{
if(is[a[i]])
q(a[i]);
ra.pb(a[i]);
}
}
for(int i = 0, lst=cur;i<n;i++)
{
if(lb.size()==mid)
{
rb.pb(b[i]);
continue;
}
if(rb.size()==n-mid)
{
lb.pb(b[i]);
continue;
}
int t = q(b[i]);
if(t==lst)
lb.pb(b[i]);
else
rb.pb(b[i]);
lst=t;
}
go(la,lb);
go(ra,rb);
}
}
void Solve(int n)
{
n1=cur=n;
vector<int> a, b;
for(int i = 1, lst = 0;i<=2*n;i++)
{
int t = q(i);
if(t==lst)
b.pb(i);
else
a.pb(i);
lst=t;
}
srand(rng());
go(a,b);
}
Compilation message
minerals.cpp: In function 'void go(std::vector<int>&, std::vector<int>&)':
minerals.cpp:50:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
50 | if(lb.size()==mid)
| ~~~~~~~~~^~~~~
minerals.cpp:55:25: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
55 | if(rb.size()==n-mid)
| ~~~~~~~~~^~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 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 |
2 ms |
336 KB |
Output is correct |
3 |
Correct |
4 ms |
464 KB |
Output is correct |
4 |
Correct |
9 ms |
760 KB |
Output is correct |
5 |
Correct |
17 ms |
1104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 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 |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
4 ms |
464 KB |
Output is correct |
8 |
Correct |
9 ms |
760 KB |
Output is correct |
9 |
Correct |
17 ms |
1104 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
13 ms |
980 KB |
Output is correct |
12 |
Correct |
17 ms |
1104 KB |
Output is correct |
13 |
Correct |
19 ms |
1196 KB |
Output is correct |
14 |
Correct |
20 ms |
1104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 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 |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
4 ms |
464 KB |
Output is correct |
8 |
Correct |
9 ms |
760 KB |
Output is correct |
9 |
Correct |
17 ms |
1104 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
13 ms |
980 KB |
Output is correct |
12 |
Correct |
17 ms |
1104 KB |
Output is correct |
13 |
Correct |
19 ms |
1196 KB |
Output is correct |
14 |
Correct |
20 ms |
1104 KB |
Output is correct |
15 |
Correct |
50 ms |
2692 KB |
Output is correct |
16 |
Correct |
52 ms |
2632 KB |
Output is correct |
17 |
Correct |
50 ms |
2664 KB |
Output is correct |
18 |
Correct |
50 ms |
2496 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 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 |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
4 ms |
464 KB |
Output is correct |
8 |
Correct |
9 ms |
760 KB |
Output is correct |
9 |
Correct |
17 ms |
1104 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
13 ms |
980 KB |
Output is correct |
12 |
Correct |
17 ms |
1104 KB |
Output is correct |
13 |
Correct |
19 ms |
1196 KB |
Output is correct |
14 |
Correct |
20 ms |
1104 KB |
Output is correct |
15 |
Correct |
50 ms |
2692 KB |
Output is correct |
16 |
Correct |
52 ms |
2632 KB |
Output is correct |
17 |
Correct |
50 ms |
2664 KB |
Output is correct |
18 |
Correct |
50 ms |
2496 KB |
Output is correct |
19 |
Correct |
56 ms |
2696 KB |
Output is correct |
20 |
Correct |
60 ms |
2708 KB |
Output is correct |
21 |
Correct |
53 ms |
2732 KB |
Output is correct |
22 |
Correct |
51 ms |
2544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 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 |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
4 ms |
464 KB |
Output is correct |
8 |
Correct |
9 ms |
760 KB |
Output is correct |
9 |
Correct |
17 ms |
1104 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
13 ms |
980 KB |
Output is correct |
12 |
Correct |
17 ms |
1104 KB |
Output is correct |
13 |
Correct |
19 ms |
1196 KB |
Output is correct |
14 |
Correct |
20 ms |
1104 KB |
Output is correct |
15 |
Correct |
50 ms |
2692 KB |
Output is correct |
16 |
Correct |
52 ms |
2632 KB |
Output is correct |
17 |
Correct |
50 ms |
2664 KB |
Output is correct |
18 |
Correct |
50 ms |
2496 KB |
Output is correct |
19 |
Correct |
56 ms |
2696 KB |
Output is correct |
20 |
Correct |
60 ms |
2708 KB |
Output is correct |
21 |
Correct |
53 ms |
2732 KB |
Output is correct |
22 |
Correct |
51 ms |
2544 KB |
Output is correct |
23 |
Correct |
56 ms |
2648 KB |
Output is correct |
24 |
Correct |
54 ms |
2756 KB |
Output is correct |
25 |
Correct |
53 ms |
2748 KB |
Output is correct |
26 |
Correct |
56 ms |
2620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 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 |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
4 ms |
464 KB |
Output is correct |
8 |
Correct |
9 ms |
760 KB |
Output is correct |
9 |
Correct |
17 ms |
1104 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
13 ms |
980 KB |
Output is correct |
12 |
Correct |
17 ms |
1104 KB |
Output is correct |
13 |
Correct |
19 ms |
1196 KB |
Output is correct |
14 |
Correct |
20 ms |
1104 KB |
Output is correct |
15 |
Correct |
50 ms |
2692 KB |
Output is correct |
16 |
Correct |
52 ms |
2632 KB |
Output is correct |
17 |
Correct |
50 ms |
2664 KB |
Output is correct |
18 |
Correct |
50 ms |
2496 KB |
Output is correct |
19 |
Correct |
56 ms |
2696 KB |
Output is correct |
20 |
Correct |
60 ms |
2708 KB |
Output is correct |
21 |
Correct |
53 ms |
2732 KB |
Output is correct |
22 |
Correct |
51 ms |
2544 KB |
Output is correct |
23 |
Correct |
56 ms |
2648 KB |
Output is correct |
24 |
Correct |
54 ms |
2756 KB |
Output is correct |
25 |
Correct |
53 ms |
2748 KB |
Output is correct |
26 |
Correct |
56 ms |
2620 KB |
Output is correct |
27 |
Correct |
54 ms |
2784 KB |
Output is correct |
28 |
Correct |
56 ms |
2840 KB |
Output is correct |
29 |
Correct |
55 ms |
2824 KB |
Output is correct |
30 |
Correct |
58 ms |
2632 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 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 |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
4 ms |
464 KB |
Output is correct |
8 |
Correct |
9 ms |
760 KB |
Output is correct |
9 |
Correct |
17 ms |
1104 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
13 ms |
980 KB |
Output is correct |
12 |
Correct |
17 ms |
1104 KB |
Output is correct |
13 |
Correct |
19 ms |
1196 KB |
Output is correct |
14 |
Correct |
20 ms |
1104 KB |
Output is correct |
15 |
Correct |
50 ms |
2692 KB |
Output is correct |
16 |
Correct |
52 ms |
2632 KB |
Output is correct |
17 |
Correct |
50 ms |
2664 KB |
Output is correct |
18 |
Correct |
50 ms |
2496 KB |
Output is correct |
19 |
Correct |
56 ms |
2696 KB |
Output is correct |
20 |
Correct |
60 ms |
2708 KB |
Output is correct |
21 |
Correct |
53 ms |
2732 KB |
Output is correct |
22 |
Correct |
51 ms |
2544 KB |
Output is correct |
23 |
Correct |
56 ms |
2648 KB |
Output is correct |
24 |
Correct |
54 ms |
2756 KB |
Output is correct |
25 |
Correct |
53 ms |
2748 KB |
Output is correct |
26 |
Correct |
56 ms |
2620 KB |
Output is correct |
27 |
Correct |
54 ms |
2784 KB |
Output is correct |
28 |
Correct |
56 ms |
2840 KB |
Output is correct |
29 |
Correct |
55 ms |
2824 KB |
Output is correct |
30 |
Correct |
58 ms |
2632 KB |
Output is correct |
31 |
Correct |
56 ms |
2852 KB |
Output is correct |
32 |
Correct |
55 ms |
2760 KB |
Output is correct |
33 |
Correct |
62 ms |
2860 KB |
Output is correct |
34 |
Correct |
57 ms |
2712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 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 |
2 ms |
336 KB |
Output is correct |
7 |
Correct |
4 ms |
464 KB |
Output is correct |
8 |
Correct |
9 ms |
760 KB |
Output is correct |
9 |
Correct |
17 ms |
1104 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
13 ms |
980 KB |
Output is correct |
12 |
Correct |
17 ms |
1104 KB |
Output is correct |
13 |
Correct |
19 ms |
1196 KB |
Output is correct |
14 |
Correct |
20 ms |
1104 KB |
Output is correct |
15 |
Correct |
50 ms |
2692 KB |
Output is correct |
16 |
Correct |
52 ms |
2632 KB |
Output is correct |
17 |
Correct |
50 ms |
2664 KB |
Output is correct |
18 |
Correct |
50 ms |
2496 KB |
Output is correct |
19 |
Correct |
56 ms |
2696 KB |
Output is correct |
20 |
Correct |
60 ms |
2708 KB |
Output is correct |
21 |
Correct |
53 ms |
2732 KB |
Output is correct |
22 |
Correct |
51 ms |
2544 KB |
Output is correct |
23 |
Correct |
56 ms |
2648 KB |
Output is correct |
24 |
Correct |
54 ms |
2756 KB |
Output is correct |
25 |
Correct |
53 ms |
2748 KB |
Output is correct |
26 |
Correct |
56 ms |
2620 KB |
Output is correct |
27 |
Correct |
54 ms |
2784 KB |
Output is correct |
28 |
Correct |
56 ms |
2840 KB |
Output is correct |
29 |
Correct |
55 ms |
2824 KB |
Output is correct |
30 |
Correct |
58 ms |
2632 KB |
Output is correct |
31 |
Correct |
56 ms |
2852 KB |
Output is correct |
32 |
Correct |
55 ms |
2760 KB |
Output is correct |
33 |
Correct |
62 ms |
2860 KB |
Output is correct |
34 |
Correct |
57 ms |
2712 KB |
Output is correct |
35 |
Incorrect |
56 ms |
2816 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |