#include <bits/stdc++.h>
#include "minerals.h"
using namespace std;
#define rep(x,s,e) for (auto x=s;x<e;x++)
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
mt19937 rng(42069);
void rec(vector<int> v, bool filled){
//for (auto &it:v) cout<<it<<" ";cout<<endl;
if (sz(v)==2){
Answer(v[0],v[1]);
if (filled) Query(v[0]),Query(v[1]);
return;
}
int ss=1;
while (ss<sz(v)/2) ss<<=1;
ss>>=1;
vector<int> l,r;
if (!filled){
for (auto &it:v){
if (sz(l)==ss*2){
r.push_back(it);
}
else if (Query(it)>ss){
r.push_back(it);
Query(it);
}
else{
l.push_back(it);
}
}
}
else{
int curr=v.size()/2;
vector<int> temp;
while (curr>ss){
curr=Query(v.back());
temp.push_back(v.back());
v.pop_back();
}
while (!v.empty()){
l.push_back(v.back());
v.pop_back();
}
for (auto &it:temp){
if (sz(l)==ss*2){
r.push_back(it);
}
else if (Query(it)>ss){
r.push_back(it);
Query(it);
}
else{
l.push_back(it);
}
}
}
rec(l,true),rec(r,false);
}
void Solve(int n) {
vector<int> v;
rep(x,1,2*n+1) v.push_back(x);
rec(v,false);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
5 ms |
640 KB |
Output is correct |
4 |
Correct |
11 ms |
896 KB |
Output is correct |
5 |
Correct |
20 ms |
1436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
11 ms |
896 KB |
Output is correct |
9 |
Correct |
20 ms |
1436 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
1152 KB |
Output is correct |
12 |
Correct |
22 ms |
1536 KB |
Output is correct |
13 |
Correct |
15 ms |
1532 KB |
Output is correct |
14 |
Correct |
21 ms |
1436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
11 ms |
896 KB |
Output is correct |
9 |
Correct |
20 ms |
1436 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
1152 KB |
Output is correct |
12 |
Correct |
22 ms |
1536 KB |
Output is correct |
13 |
Correct |
15 ms |
1532 KB |
Output is correct |
14 |
Correct |
21 ms |
1436 KB |
Output is correct |
15 |
Incorrect |
35 ms |
3568 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
11 ms |
896 KB |
Output is correct |
9 |
Correct |
20 ms |
1436 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
1152 KB |
Output is correct |
12 |
Correct |
22 ms |
1536 KB |
Output is correct |
13 |
Correct |
15 ms |
1532 KB |
Output is correct |
14 |
Correct |
21 ms |
1436 KB |
Output is correct |
15 |
Incorrect |
35 ms |
3568 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
11 ms |
896 KB |
Output is correct |
9 |
Correct |
20 ms |
1436 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
1152 KB |
Output is correct |
12 |
Correct |
22 ms |
1536 KB |
Output is correct |
13 |
Correct |
15 ms |
1532 KB |
Output is correct |
14 |
Correct |
21 ms |
1436 KB |
Output is correct |
15 |
Incorrect |
35 ms |
3568 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
11 ms |
896 KB |
Output is correct |
9 |
Correct |
20 ms |
1436 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
1152 KB |
Output is correct |
12 |
Correct |
22 ms |
1536 KB |
Output is correct |
13 |
Correct |
15 ms |
1532 KB |
Output is correct |
14 |
Correct |
21 ms |
1436 KB |
Output is correct |
15 |
Incorrect |
35 ms |
3568 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
11 ms |
896 KB |
Output is correct |
9 |
Correct |
20 ms |
1436 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
1152 KB |
Output is correct |
12 |
Correct |
22 ms |
1536 KB |
Output is correct |
13 |
Correct |
15 ms |
1532 KB |
Output is correct |
14 |
Correct |
21 ms |
1436 KB |
Output is correct |
15 |
Incorrect |
35 ms |
3568 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
5 ms |
640 KB |
Output is correct |
8 |
Correct |
11 ms |
896 KB |
Output is correct |
9 |
Correct |
20 ms |
1436 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
14 ms |
1152 KB |
Output is correct |
12 |
Correct |
22 ms |
1536 KB |
Output is correct |
13 |
Correct |
15 ms |
1532 KB |
Output is correct |
14 |
Correct |
21 ms |
1436 KB |
Output is correct |
15 |
Incorrect |
35 ms |
3568 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |