//#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
#define endl '\n'
#include "minerals.h"
vector<pair<int,int>> ans;
int cur=0;
set<int> xx;
mt19937 rng;
void solve(vector<int> aa,vector<int> bb,int y=0){
rng=mt19937(chrono::steady_clock::now().time_since_epoch().count());
/*for(auto j:aa){
cout<<j<<".";
}
cout<<endl;
for(auto j:bb){
cout<<j<<".";
}
cout<<endl;*/
if(aa.size()==1){
//cout<<aa[0]<<":"<<bb[0]<<endl;
ans.pb({aa[0],bb[0]});
return;
}
//int cur=0;
vector<int> cc;
vector<int> dd;
vector<int> ee;
vector<int> ff;
int x=aa.size()/2;
if(aa.size()>4){
x+=(aa.size()*4)/34;
}
/* if(aa.size()>64){
x+=10;
}
else if(aa.size()>
else if(aa.size()>16){
x+=4;
}
else if(aa.size()>8){
x+=2;//=2;
}
else if(aa.size()>2){
x++;
}*/
for(int i=0;i<aa.size();i++){
if(i<x){
dd.pb(aa[i]);
continue;
}
cur=Query(aa[i]);
xx.insert(aa[i]);
cc.pb(aa[i]);
}
shuffle(bb.begin(),bb.end(),rng);
for(int i=0;i+1<bb.size();i++){
if(ee.size()==cc.size()){
for(int j=i;j+1<bb.size();j++){
ff.pb(bb[j]);
}
break;
}
else if(dd.size()==ff.size()){
for(int j=i;j+1<bb.size();j++){
ee.pb(bb[j]);
}
break;
}
int cur2=Query(bb[i]);
/* if(bb.size()==4){
cout<<cur<<","<<cur2<<","<<bb[i]<<endl;
}*/
if(y==0 and cur2==cur){
ee.pb(bb[i]);
continue;
}
else if(y==1 and cur2!=cur){
cur=cur2;
ee.pb(bb[i]);
continue;
}
//Query(bb[i]);
cur=cur2;
ff.pb(bb[i]);
}
if(ee.size()<cc.size()){
ee.pb(bb.back());
}
else{
ff.pb(bb.back());
}
/*for(auto j:cc){
cur=Query(j);
}*/
/*for(auto j:cc){
cout<<j<<",";
}
cout<<endl;
for(auto j:ee){
cout<<j<<",";
}
cout<<endl<<endl;;*/
solve(cc,ee,y^1);
solve(dd,ff,y);
}
void Solve(int n) {
vector<int> aa;
vector<int> bb;
int cur5=0;
for(int i=1;i<=2*n;i++){
int cur2=Query(i);
if(cur2>cur5){
aa.pb(i);
cur5=cur2;
continue;
}
bb.pb(i);
//Query(i);
}
/* for(auto j:aa){
Query(j);
}
*/
solve(aa,bb,1);
for (int i=0; i<n;i++) {
Answer(ans[i].a,ans[i].b);
}
}
Compilation message
minerals.cpp: In function 'void solve(std::vector<int>, std::vector<int>, int)':
minerals.cpp:54:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for(int i=0;i<aa.size();i++){
| ~^~~~~~~~~~
minerals.cpp:64:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | for(int i=0;i+1<bb.size();i++){
| ~~~^~~~~~~~~~
minerals.cpp:66:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
66 | for(int j=i;j+1<bb.size();j++){
| ~~~^~~~~~~~~~
minerals.cpp:72:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | for(int j=i;j+1<bb.size();j++){
| ~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
11 ms |
472 KB |
Output is correct |
2 |
Correct |
23 ms |
596 KB |
Output is correct |
3 |
Correct |
48 ms |
936 KB |
Output is correct |
4 |
Correct |
91 ms |
1452 KB |
Output is correct |
5 |
Correct |
174 ms |
2480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
11 ms |
472 KB |
Output is correct |
6 |
Correct |
23 ms |
596 KB |
Output is correct |
7 |
Correct |
48 ms |
936 KB |
Output is correct |
8 |
Correct |
91 ms |
1452 KB |
Output is correct |
9 |
Correct |
174 ms |
2480 KB |
Output is correct |
10 |
Correct |
12 ms |
488 KB |
Output is correct |
11 |
Correct |
119 ms |
1724 KB |
Output is correct |
12 |
Correct |
208 ms |
2452 KB |
Output is correct |
13 |
Correct |
177 ms |
2492 KB |
Output is correct |
14 |
Correct |
175 ms |
2356 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
11 ms |
472 KB |
Output is correct |
6 |
Correct |
23 ms |
596 KB |
Output is correct |
7 |
Correct |
48 ms |
936 KB |
Output is correct |
8 |
Correct |
91 ms |
1452 KB |
Output is correct |
9 |
Correct |
174 ms |
2480 KB |
Output is correct |
10 |
Correct |
12 ms |
488 KB |
Output is correct |
11 |
Correct |
119 ms |
1724 KB |
Output is correct |
12 |
Correct |
208 ms |
2452 KB |
Output is correct |
13 |
Correct |
177 ms |
2492 KB |
Output is correct |
14 |
Correct |
175 ms |
2356 KB |
Output is correct |
15 |
Correct |
502 ms |
5416 KB |
Output is correct |
16 |
Correct |
447 ms |
5392 KB |
Output is correct |
17 |
Correct |
430 ms |
5460 KB |
Output is correct |
18 |
Correct |
451 ms |
5272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
11 ms |
472 KB |
Output is correct |
6 |
Correct |
23 ms |
596 KB |
Output is correct |
7 |
Correct |
48 ms |
936 KB |
Output is correct |
8 |
Correct |
91 ms |
1452 KB |
Output is correct |
9 |
Correct |
174 ms |
2480 KB |
Output is correct |
10 |
Correct |
12 ms |
488 KB |
Output is correct |
11 |
Correct |
119 ms |
1724 KB |
Output is correct |
12 |
Correct |
208 ms |
2452 KB |
Output is correct |
13 |
Correct |
177 ms |
2492 KB |
Output is correct |
14 |
Correct |
175 ms |
2356 KB |
Output is correct |
15 |
Correct |
502 ms |
5416 KB |
Output is correct |
16 |
Correct |
447 ms |
5392 KB |
Output is correct |
17 |
Correct |
430 ms |
5460 KB |
Output is correct |
18 |
Correct |
451 ms |
5272 KB |
Output is correct |
19 |
Correct |
468 ms |
5532 KB |
Output is correct |
20 |
Correct |
468 ms |
5520 KB |
Output is correct |
21 |
Correct |
445 ms |
5640 KB |
Output is correct |
22 |
Correct |
463 ms |
5384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
11 ms |
472 KB |
Output is correct |
6 |
Correct |
23 ms |
596 KB |
Output is correct |
7 |
Correct |
48 ms |
936 KB |
Output is correct |
8 |
Correct |
91 ms |
1452 KB |
Output is correct |
9 |
Correct |
174 ms |
2480 KB |
Output is correct |
10 |
Correct |
12 ms |
488 KB |
Output is correct |
11 |
Correct |
119 ms |
1724 KB |
Output is correct |
12 |
Correct |
208 ms |
2452 KB |
Output is correct |
13 |
Correct |
177 ms |
2492 KB |
Output is correct |
14 |
Correct |
175 ms |
2356 KB |
Output is correct |
15 |
Correct |
502 ms |
5416 KB |
Output is correct |
16 |
Correct |
447 ms |
5392 KB |
Output is correct |
17 |
Correct |
430 ms |
5460 KB |
Output is correct |
18 |
Correct |
451 ms |
5272 KB |
Output is correct |
19 |
Correct |
468 ms |
5532 KB |
Output is correct |
20 |
Correct |
468 ms |
5520 KB |
Output is correct |
21 |
Correct |
445 ms |
5640 KB |
Output is correct |
22 |
Correct |
463 ms |
5384 KB |
Output is correct |
23 |
Correct |
506 ms |
5684 KB |
Output is correct |
24 |
Correct |
468 ms |
5660 KB |
Output is correct |
25 |
Correct |
480 ms |
5804 KB |
Output is correct |
26 |
Correct |
468 ms |
5492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
11 ms |
472 KB |
Output is correct |
6 |
Correct |
23 ms |
596 KB |
Output is correct |
7 |
Correct |
48 ms |
936 KB |
Output is correct |
8 |
Correct |
91 ms |
1452 KB |
Output is correct |
9 |
Correct |
174 ms |
2480 KB |
Output is correct |
10 |
Correct |
12 ms |
488 KB |
Output is correct |
11 |
Correct |
119 ms |
1724 KB |
Output is correct |
12 |
Correct |
208 ms |
2452 KB |
Output is correct |
13 |
Correct |
177 ms |
2492 KB |
Output is correct |
14 |
Correct |
175 ms |
2356 KB |
Output is correct |
15 |
Correct |
502 ms |
5416 KB |
Output is correct |
16 |
Correct |
447 ms |
5392 KB |
Output is correct |
17 |
Correct |
430 ms |
5460 KB |
Output is correct |
18 |
Correct |
451 ms |
5272 KB |
Output is correct |
19 |
Correct |
468 ms |
5532 KB |
Output is correct |
20 |
Correct |
468 ms |
5520 KB |
Output is correct |
21 |
Correct |
445 ms |
5640 KB |
Output is correct |
22 |
Correct |
463 ms |
5384 KB |
Output is correct |
23 |
Correct |
506 ms |
5684 KB |
Output is correct |
24 |
Correct |
468 ms |
5660 KB |
Output is correct |
25 |
Correct |
480 ms |
5804 KB |
Output is correct |
26 |
Correct |
468 ms |
5492 KB |
Output is correct |
27 |
Correct |
497 ms |
5804 KB |
Output is correct |
28 |
Correct |
479 ms |
5788 KB |
Output is correct |
29 |
Correct |
467 ms |
5840 KB |
Output is correct |
30 |
Correct |
513 ms |
5584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
11 ms |
472 KB |
Output is correct |
6 |
Correct |
23 ms |
596 KB |
Output is correct |
7 |
Correct |
48 ms |
936 KB |
Output is correct |
8 |
Correct |
91 ms |
1452 KB |
Output is correct |
9 |
Correct |
174 ms |
2480 KB |
Output is correct |
10 |
Correct |
12 ms |
488 KB |
Output is correct |
11 |
Correct |
119 ms |
1724 KB |
Output is correct |
12 |
Correct |
208 ms |
2452 KB |
Output is correct |
13 |
Correct |
177 ms |
2492 KB |
Output is correct |
14 |
Correct |
175 ms |
2356 KB |
Output is correct |
15 |
Correct |
502 ms |
5416 KB |
Output is correct |
16 |
Correct |
447 ms |
5392 KB |
Output is correct |
17 |
Correct |
430 ms |
5460 KB |
Output is correct |
18 |
Correct |
451 ms |
5272 KB |
Output is correct |
19 |
Correct |
468 ms |
5532 KB |
Output is correct |
20 |
Correct |
468 ms |
5520 KB |
Output is correct |
21 |
Correct |
445 ms |
5640 KB |
Output is correct |
22 |
Correct |
463 ms |
5384 KB |
Output is correct |
23 |
Correct |
506 ms |
5684 KB |
Output is correct |
24 |
Correct |
468 ms |
5660 KB |
Output is correct |
25 |
Correct |
480 ms |
5804 KB |
Output is correct |
26 |
Correct |
468 ms |
5492 KB |
Output is correct |
27 |
Correct |
497 ms |
5804 KB |
Output is correct |
28 |
Correct |
479 ms |
5788 KB |
Output is correct |
29 |
Correct |
467 ms |
5840 KB |
Output is correct |
30 |
Correct |
513 ms |
5584 KB |
Output is correct |
31 |
Correct |
521 ms |
5896 KB |
Output is correct |
32 |
Correct |
525 ms |
5912 KB |
Output is correct |
33 |
Correct |
492 ms |
6036 KB |
Output is correct |
34 |
Correct |
510 ms |
5904 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
336 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
5 |
Correct |
11 ms |
472 KB |
Output is correct |
6 |
Correct |
23 ms |
596 KB |
Output is correct |
7 |
Correct |
48 ms |
936 KB |
Output is correct |
8 |
Correct |
91 ms |
1452 KB |
Output is correct |
9 |
Correct |
174 ms |
2480 KB |
Output is correct |
10 |
Correct |
12 ms |
488 KB |
Output is correct |
11 |
Correct |
119 ms |
1724 KB |
Output is correct |
12 |
Correct |
208 ms |
2452 KB |
Output is correct |
13 |
Correct |
177 ms |
2492 KB |
Output is correct |
14 |
Correct |
175 ms |
2356 KB |
Output is correct |
15 |
Correct |
502 ms |
5416 KB |
Output is correct |
16 |
Correct |
447 ms |
5392 KB |
Output is correct |
17 |
Correct |
430 ms |
5460 KB |
Output is correct |
18 |
Correct |
451 ms |
5272 KB |
Output is correct |
19 |
Correct |
468 ms |
5532 KB |
Output is correct |
20 |
Correct |
468 ms |
5520 KB |
Output is correct |
21 |
Correct |
445 ms |
5640 KB |
Output is correct |
22 |
Correct |
463 ms |
5384 KB |
Output is correct |
23 |
Correct |
506 ms |
5684 KB |
Output is correct |
24 |
Correct |
468 ms |
5660 KB |
Output is correct |
25 |
Correct |
480 ms |
5804 KB |
Output is correct |
26 |
Correct |
468 ms |
5492 KB |
Output is correct |
27 |
Correct |
497 ms |
5804 KB |
Output is correct |
28 |
Correct |
479 ms |
5788 KB |
Output is correct |
29 |
Correct |
467 ms |
5840 KB |
Output is correct |
30 |
Correct |
513 ms |
5584 KB |
Output is correct |
31 |
Correct |
521 ms |
5896 KB |
Output is correct |
32 |
Correct |
525 ms |
5912 KB |
Output is correct |
33 |
Correct |
492 ms |
6036 KB |
Output is correct |
34 |
Correct |
510 ms |
5904 KB |
Output is correct |
35 |
Correct |
517 ms |
6120 KB |
Output is correct |
36 |
Correct |
505 ms |
6136 KB |
Output is correct |
37 |
Correct |
522 ms |
6304 KB |
Output is correct |
38 |
Correct |
515 ms |
5940 KB |
Output is correct |