//#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;
void solve(vector<int> aa,vector<int> bb,int y=0){
/*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()>16){
x+=3;
}
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]);
}
for(int i=0;i<bb.size();i++){
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]);
}
/*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:45:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | for(int i=0;i<aa.size();i++){
| ~^~~~~~~~~~
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<bb.size();i++){
| ~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
336 KB |
Output is correct |
2 |
Correct |
4 ms |
464 KB |
Output is correct |
3 |
Correct |
7 ms |
720 KB |
Output is correct |
4 |
Correct |
12 ms |
1232 KB |
Output is correct |
5 |
Correct |
23 ms |
2128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
4 ms |
464 KB |
Output is correct |
7 |
Correct |
7 ms |
720 KB |
Output is correct |
8 |
Correct |
12 ms |
1232 KB |
Output is correct |
9 |
Correct |
23 ms |
2128 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
14 ms |
1588 KB |
Output is correct |
12 |
Correct |
21 ms |
2136 KB |
Output is correct |
13 |
Correct |
20 ms |
2196 KB |
Output is correct |
14 |
Correct |
27 ms |
2308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
4 ms |
464 KB |
Output is correct |
7 |
Correct |
7 ms |
720 KB |
Output is correct |
8 |
Correct |
12 ms |
1232 KB |
Output is correct |
9 |
Correct |
23 ms |
2128 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
14 ms |
1588 KB |
Output is correct |
12 |
Correct |
21 ms |
2136 KB |
Output is correct |
13 |
Correct |
20 ms |
2196 KB |
Output is correct |
14 |
Correct |
27 ms |
2308 KB |
Output is correct |
15 |
Correct |
81 ms |
4964 KB |
Output is correct |
16 |
Correct |
61 ms |
4936 KB |
Output is correct |
17 |
Correct |
65 ms |
5032 KB |
Output is correct |
18 |
Correct |
66 ms |
4780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
4 ms |
464 KB |
Output is correct |
7 |
Correct |
7 ms |
720 KB |
Output is correct |
8 |
Correct |
12 ms |
1232 KB |
Output is correct |
9 |
Correct |
23 ms |
2128 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
14 ms |
1588 KB |
Output is correct |
12 |
Correct |
21 ms |
2136 KB |
Output is correct |
13 |
Correct |
20 ms |
2196 KB |
Output is correct |
14 |
Correct |
27 ms |
2308 KB |
Output is correct |
15 |
Correct |
81 ms |
4964 KB |
Output is correct |
16 |
Correct |
61 ms |
4936 KB |
Output is correct |
17 |
Correct |
65 ms |
5032 KB |
Output is correct |
18 |
Correct |
66 ms |
4780 KB |
Output is correct |
19 |
Correct |
72 ms |
5076 KB |
Output is correct |
20 |
Correct |
71 ms |
5044 KB |
Output is correct |
21 |
Correct |
79 ms |
5156 KB |
Output is correct |
22 |
Correct |
64 ms |
4912 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
4 ms |
464 KB |
Output is correct |
7 |
Correct |
7 ms |
720 KB |
Output is correct |
8 |
Correct |
12 ms |
1232 KB |
Output is correct |
9 |
Correct |
23 ms |
2128 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
14 ms |
1588 KB |
Output is correct |
12 |
Correct |
21 ms |
2136 KB |
Output is correct |
13 |
Correct |
20 ms |
2196 KB |
Output is correct |
14 |
Correct |
27 ms |
2308 KB |
Output is correct |
15 |
Correct |
81 ms |
4964 KB |
Output is correct |
16 |
Correct |
61 ms |
4936 KB |
Output is correct |
17 |
Correct |
65 ms |
5032 KB |
Output is correct |
18 |
Correct |
66 ms |
4780 KB |
Output is correct |
19 |
Correct |
72 ms |
5076 KB |
Output is correct |
20 |
Correct |
71 ms |
5044 KB |
Output is correct |
21 |
Correct |
79 ms |
5156 KB |
Output is correct |
22 |
Correct |
64 ms |
4912 KB |
Output is correct |
23 |
Incorrect |
58 ms |
5152 KB |
Wrong Answer [2] |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
4 ms |
464 KB |
Output is correct |
7 |
Correct |
7 ms |
720 KB |
Output is correct |
8 |
Correct |
12 ms |
1232 KB |
Output is correct |
9 |
Correct |
23 ms |
2128 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
14 ms |
1588 KB |
Output is correct |
12 |
Correct |
21 ms |
2136 KB |
Output is correct |
13 |
Correct |
20 ms |
2196 KB |
Output is correct |
14 |
Correct |
27 ms |
2308 KB |
Output is correct |
15 |
Correct |
81 ms |
4964 KB |
Output is correct |
16 |
Correct |
61 ms |
4936 KB |
Output is correct |
17 |
Correct |
65 ms |
5032 KB |
Output is correct |
18 |
Correct |
66 ms |
4780 KB |
Output is correct |
19 |
Correct |
72 ms |
5076 KB |
Output is correct |
20 |
Correct |
71 ms |
5044 KB |
Output is correct |
21 |
Correct |
79 ms |
5156 KB |
Output is correct |
22 |
Correct |
64 ms |
4912 KB |
Output is correct |
23 |
Incorrect |
58 ms |
5152 KB |
Wrong Answer [2] |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
4 ms |
464 KB |
Output is correct |
7 |
Correct |
7 ms |
720 KB |
Output is correct |
8 |
Correct |
12 ms |
1232 KB |
Output is correct |
9 |
Correct |
23 ms |
2128 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
14 ms |
1588 KB |
Output is correct |
12 |
Correct |
21 ms |
2136 KB |
Output is correct |
13 |
Correct |
20 ms |
2196 KB |
Output is correct |
14 |
Correct |
27 ms |
2308 KB |
Output is correct |
15 |
Correct |
81 ms |
4964 KB |
Output is correct |
16 |
Correct |
61 ms |
4936 KB |
Output is correct |
17 |
Correct |
65 ms |
5032 KB |
Output is correct |
18 |
Correct |
66 ms |
4780 KB |
Output is correct |
19 |
Correct |
72 ms |
5076 KB |
Output is correct |
20 |
Correct |
71 ms |
5044 KB |
Output is correct |
21 |
Correct |
79 ms |
5156 KB |
Output is correct |
22 |
Correct |
64 ms |
4912 KB |
Output is correct |
23 |
Incorrect |
58 ms |
5152 KB |
Wrong Answer [2] |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
336 KB |
Output is correct |
6 |
Correct |
4 ms |
464 KB |
Output is correct |
7 |
Correct |
7 ms |
720 KB |
Output is correct |
8 |
Correct |
12 ms |
1232 KB |
Output is correct |
9 |
Correct |
23 ms |
2128 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
14 ms |
1588 KB |
Output is correct |
12 |
Correct |
21 ms |
2136 KB |
Output is correct |
13 |
Correct |
20 ms |
2196 KB |
Output is correct |
14 |
Correct |
27 ms |
2308 KB |
Output is correct |
15 |
Correct |
81 ms |
4964 KB |
Output is correct |
16 |
Correct |
61 ms |
4936 KB |
Output is correct |
17 |
Correct |
65 ms |
5032 KB |
Output is correct |
18 |
Correct |
66 ms |
4780 KB |
Output is correct |
19 |
Correct |
72 ms |
5076 KB |
Output is correct |
20 |
Correct |
71 ms |
5044 KB |
Output is correct |
21 |
Correct |
79 ms |
5156 KB |
Output is correct |
22 |
Correct |
64 ms |
4912 KB |
Output is correct |
23 |
Incorrect |
58 ms |
5152 KB |
Wrong Answer [2] |
24 |
Halted |
0 ms |
0 KB |
- |