#include "minerals.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
mt19937 rnd(time(0));
int last=0;
vector<int> have(100000);
int ask(int k){
have[k] ^= 1;
int p = Query(k);
int tmp = p - last;
last = p;
return tmp;
}
void dc(vector<int> &a,vector<int> &b){
int n=a.size();
if(n==1){
Answer(a[0],b[0]);
return;
}
int m=max(1,n*48/100);
int sz1=0,sz2=0;
vector<int> a1,a2,b1,b2,tmp1,tmp2;
for(int i=0;i<n;i++){
if(have[a[i]]){
sz1++;
}
if(have[b[i]]){
sz2++;
}
}
if(abs(m-sz2)<abs(m-sz1)){
swap(a,b);
swap(tmp1,tmp2);
swap(sz1,sz2);
}
for(int i=0;i<n;i++){
if(have[a[i]]){
tmp1.push_back(a[i]);
}
else{
tmp2.push_back(a[i]);
}
}
if(sz1>m){
int t=abs(m-sz1);
for(int i=0;i<t;i++){
ask(tmp1[i]);
}
}
else{
int t=abs(m-sz1);
for(int i=0;i<t;i++){
ask(tmp2[i]);
}
}
for(int i=0;i<n;i++){
if(have[a[i]]){
a1.push_back(a[i]);
}
else{
a2.push_back(a[i]);
}
}
shuffle(b.begin(),b.end(),rnd);
int cnt=0;
for(int i=0;i<n;i++){
if(cnt==m){
b2.push_back(b[i]);
continue;
}
if(ask(b[i])==0){
cnt++;
b1.push_back(b[i]);
}
else{
b2.push_back(b[i]);
}
}
dc(a1,b1);
dc(a2,b2);
}
void Solve(int n) {
vector<int> a,b;
vector<int> t(n*2);
iota(t.begin(),t.end(),1);
shuffle(t.begin(),t.end(),rnd);
for(int j=0;j<n*2;j++){
int i=t[j];
if(ask(i)==0){
b.push_back(i);
}
else{
a.push_back(i);
}
}
dc(a,b);
}
/*
times: N*2 + N log N * 3/2
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
856 KB |
Output is correct |
3 |
Correct |
1 ms |
856 KB |
Output is correct |
4 |
Correct |
1 ms |
856 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
856 KB |
Output is correct |
2 |
Correct |
2 ms |
856 KB |
Output is correct |
3 |
Correct |
4 ms |
1112 KB |
Output is correct |
4 |
Correct |
8 ms |
1420 KB |
Output is correct |
5 |
Correct |
16 ms |
1952 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
856 KB |
Output is correct |
3 |
Correct |
1 ms |
856 KB |
Output is correct |
4 |
Correct |
1 ms |
856 KB |
Output is correct |
5 |
Correct |
1 ms |
856 KB |
Output is correct |
6 |
Correct |
2 ms |
856 KB |
Output is correct |
7 |
Correct |
4 ms |
1112 KB |
Output is correct |
8 |
Correct |
8 ms |
1420 KB |
Output is correct |
9 |
Correct |
16 ms |
1952 KB |
Output is correct |
10 |
Correct |
1 ms |
856 KB |
Output is correct |
11 |
Correct |
11 ms |
1436 KB |
Output is correct |
12 |
Correct |
16 ms |
1984 KB |
Output is correct |
13 |
Correct |
16 ms |
2196 KB |
Output is correct |
14 |
Correct |
16 ms |
2196 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
856 KB |
Output is correct |
3 |
Correct |
1 ms |
856 KB |
Output is correct |
4 |
Correct |
1 ms |
856 KB |
Output is correct |
5 |
Correct |
1 ms |
856 KB |
Output is correct |
6 |
Correct |
2 ms |
856 KB |
Output is correct |
7 |
Correct |
4 ms |
1112 KB |
Output is correct |
8 |
Correct |
8 ms |
1420 KB |
Output is correct |
9 |
Correct |
16 ms |
1952 KB |
Output is correct |
10 |
Correct |
1 ms |
856 KB |
Output is correct |
11 |
Correct |
11 ms |
1436 KB |
Output is correct |
12 |
Correct |
16 ms |
1984 KB |
Output is correct |
13 |
Correct |
16 ms |
2196 KB |
Output is correct |
14 |
Correct |
16 ms |
2196 KB |
Output is correct |
15 |
Correct |
46 ms |
3776 KB |
Output is correct |
16 |
Correct |
52 ms |
4240 KB |
Output is correct |
17 |
Correct |
45 ms |
4136 KB |
Output is correct |
18 |
Correct |
43 ms |
3660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
856 KB |
Output is correct |
3 |
Correct |
1 ms |
856 KB |
Output is correct |
4 |
Correct |
1 ms |
856 KB |
Output is correct |
5 |
Correct |
1 ms |
856 KB |
Output is correct |
6 |
Correct |
2 ms |
856 KB |
Output is correct |
7 |
Correct |
4 ms |
1112 KB |
Output is correct |
8 |
Correct |
8 ms |
1420 KB |
Output is correct |
9 |
Correct |
16 ms |
1952 KB |
Output is correct |
10 |
Correct |
1 ms |
856 KB |
Output is correct |
11 |
Correct |
11 ms |
1436 KB |
Output is correct |
12 |
Correct |
16 ms |
1984 KB |
Output is correct |
13 |
Correct |
16 ms |
2196 KB |
Output is correct |
14 |
Correct |
16 ms |
2196 KB |
Output is correct |
15 |
Correct |
46 ms |
3776 KB |
Output is correct |
16 |
Correct |
52 ms |
4240 KB |
Output is correct |
17 |
Correct |
45 ms |
4136 KB |
Output is correct |
18 |
Correct |
43 ms |
3660 KB |
Output is correct |
19 |
Correct |
47 ms |
3844 KB |
Output is correct |
20 |
Correct |
45 ms |
3796 KB |
Output is correct |
21 |
Correct |
44 ms |
4172 KB |
Output is correct |
22 |
Correct |
44 ms |
3964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
856 KB |
Output is correct |
3 |
Correct |
1 ms |
856 KB |
Output is correct |
4 |
Correct |
1 ms |
856 KB |
Output is correct |
5 |
Correct |
1 ms |
856 KB |
Output is correct |
6 |
Correct |
2 ms |
856 KB |
Output is correct |
7 |
Correct |
4 ms |
1112 KB |
Output is correct |
8 |
Correct |
8 ms |
1420 KB |
Output is correct |
9 |
Correct |
16 ms |
1952 KB |
Output is correct |
10 |
Correct |
1 ms |
856 KB |
Output is correct |
11 |
Correct |
11 ms |
1436 KB |
Output is correct |
12 |
Correct |
16 ms |
1984 KB |
Output is correct |
13 |
Correct |
16 ms |
2196 KB |
Output is correct |
14 |
Correct |
16 ms |
2196 KB |
Output is correct |
15 |
Correct |
46 ms |
3776 KB |
Output is correct |
16 |
Correct |
52 ms |
4240 KB |
Output is correct |
17 |
Correct |
45 ms |
4136 KB |
Output is correct |
18 |
Correct |
43 ms |
3660 KB |
Output is correct |
19 |
Correct |
47 ms |
3844 KB |
Output is correct |
20 |
Correct |
45 ms |
3796 KB |
Output is correct |
21 |
Correct |
44 ms |
4172 KB |
Output is correct |
22 |
Correct |
44 ms |
3964 KB |
Output is correct |
23 |
Correct |
47 ms |
3848 KB |
Output is correct |
24 |
Correct |
46 ms |
3856 KB |
Output is correct |
25 |
Correct |
47 ms |
4208 KB |
Output is correct |
26 |
Correct |
45 ms |
3988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
856 KB |
Output is correct |
3 |
Correct |
1 ms |
856 KB |
Output is correct |
4 |
Correct |
1 ms |
856 KB |
Output is correct |
5 |
Correct |
1 ms |
856 KB |
Output is correct |
6 |
Correct |
2 ms |
856 KB |
Output is correct |
7 |
Correct |
4 ms |
1112 KB |
Output is correct |
8 |
Correct |
8 ms |
1420 KB |
Output is correct |
9 |
Correct |
16 ms |
1952 KB |
Output is correct |
10 |
Correct |
1 ms |
856 KB |
Output is correct |
11 |
Correct |
11 ms |
1436 KB |
Output is correct |
12 |
Correct |
16 ms |
1984 KB |
Output is correct |
13 |
Correct |
16 ms |
2196 KB |
Output is correct |
14 |
Correct |
16 ms |
2196 KB |
Output is correct |
15 |
Correct |
46 ms |
3776 KB |
Output is correct |
16 |
Correct |
52 ms |
4240 KB |
Output is correct |
17 |
Correct |
45 ms |
4136 KB |
Output is correct |
18 |
Correct |
43 ms |
3660 KB |
Output is correct |
19 |
Correct |
47 ms |
3844 KB |
Output is correct |
20 |
Correct |
45 ms |
3796 KB |
Output is correct |
21 |
Correct |
44 ms |
4172 KB |
Output is correct |
22 |
Correct |
44 ms |
3964 KB |
Output is correct |
23 |
Correct |
47 ms |
3848 KB |
Output is correct |
24 |
Correct |
46 ms |
3856 KB |
Output is correct |
25 |
Correct |
47 ms |
4208 KB |
Output is correct |
26 |
Correct |
45 ms |
3988 KB |
Output is correct |
27 |
Correct |
55 ms |
3964 KB |
Output is correct |
28 |
Correct |
48 ms |
4000 KB |
Output is correct |
29 |
Correct |
49 ms |
3864 KB |
Output is correct |
30 |
Correct |
47 ms |
3716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
856 KB |
Output is correct |
3 |
Correct |
1 ms |
856 KB |
Output is correct |
4 |
Correct |
1 ms |
856 KB |
Output is correct |
5 |
Correct |
1 ms |
856 KB |
Output is correct |
6 |
Correct |
2 ms |
856 KB |
Output is correct |
7 |
Correct |
4 ms |
1112 KB |
Output is correct |
8 |
Correct |
8 ms |
1420 KB |
Output is correct |
9 |
Correct |
16 ms |
1952 KB |
Output is correct |
10 |
Correct |
1 ms |
856 KB |
Output is correct |
11 |
Correct |
11 ms |
1436 KB |
Output is correct |
12 |
Correct |
16 ms |
1984 KB |
Output is correct |
13 |
Correct |
16 ms |
2196 KB |
Output is correct |
14 |
Correct |
16 ms |
2196 KB |
Output is correct |
15 |
Correct |
46 ms |
3776 KB |
Output is correct |
16 |
Correct |
52 ms |
4240 KB |
Output is correct |
17 |
Correct |
45 ms |
4136 KB |
Output is correct |
18 |
Correct |
43 ms |
3660 KB |
Output is correct |
19 |
Correct |
47 ms |
3844 KB |
Output is correct |
20 |
Correct |
45 ms |
3796 KB |
Output is correct |
21 |
Correct |
44 ms |
4172 KB |
Output is correct |
22 |
Correct |
44 ms |
3964 KB |
Output is correct |
23 |
Correct |
47 ms |
3848 KB |
Output is correct |
24 |
Correct |
46 ms |
3856 KB |
Output is correct |
25 |
Correct |
47 ms |
4208 KB |
Output is correct |
26 |
Correct |
45 ms |
3988 KB |
Output is correct |
27 |
Correct |
55 ms |
3964 KB |
Output is correct |
28 |
Correct |
48 ms |
4000 KB |
Output is correct |
29 |
Correct |
49 ms |
3864 KB |
Output is correct |
30 |
Correct |
47 ms |
3716 KB |
Output is correct |
31 |
Correct |
48 ms |
3860 KB |
Output is correct |
32 |
Correct |
49 ms |
4008 KB |
Output is correct |
33 |
Correct |
47 ms |
4216 KB |
Output is correct |
34 |
Correct |
47 ms |
3672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
856 KB |
Output is correct |
3 |
Correct |
1 ms |
856 KB |
Output is correct |
4 |
Correct |
1 ms |
856 KB |
Output is correct |
5 |
Correct |
1 ms |
856 KB |
Output is correct |
6 |
Correct |
2 ms |
856 KB |
Output is correct |
7 |
Correct |
4 ms |
1112 KB |
Output is correct |
8 |
Correct |
8 ms |
1420 KB |
Output is correct |
9 |
Correct |
16 ms |
1952 KB |
Output is correct |
10 |
Correct |
1 ms |
856 KB |
Output is correct |
11 |
Correct |
11 ms |
1436 KB |
Output is correct |
12 |
Correct |
16 ms |
1984 KB |
Output is correct |
13 |
Correct |
16 ms |
2196 KB |
Output is correct |
14 |
Correct |
16 ms |
2196 KB |
Output is correct |
15 |
Correct |
46 ms |
3776 KB |
Output is correct |
16 |
Correct |
52 ms |
4240 KB |
Output is correct |
17 |
Correct |
45 ms |
4136 KB |
Output is correct |
18 |
Correct |
43 ms |
3660 KB |
Output is correct |
19 |
Correct |
47 ms |
3844 KB |
Output is correct |
20 |
Correct |
45 ms |
3796 KB |
Output is correct |
21 |
Correct |
44 ms |
4172 KB |
Output is correct |
22 |
Correct |
44 ms |
3964 KB |
Output is correct |
23 |
Correct |
47 ms |
3848 KB |
Output is correct |
24 |
Correct |
46 ms |
3856 KB |
Output is correct |
25 |
Correct |
47 ms |
4208 KB |
Output is correct |
26 |
Correct |
45 ms |
3988 KB |
Output is correct |
27 |
Correct |
55 ms |
3964 KB |
Output is correct |
28 |
Correct |
48 ms |
4000 KB |
Output is correct |
29 |
Correct |
49 ms |
3864 KB |
Output is correct |
30 |
Correct |
47 ms |
3716 KB |
Output is correct |
31 |
Correct |
48 ms |
3860 KB |
Output is correct |
32 |
Correct |
49 ms |
4008 KB |
Output is correct |
33 |
Correct |
47 ms |
4216 KB |
Output is correct |
34 |
Correct |
47 ms |
3672 KB |
Output is correct |
35 |
Incorrect |
48 ms |
4032 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |