#include"minerals.h"
#include<bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<int>arr;
void Merge(int l,int r,vector<int>have){
if (l==r){
// cout<<"match "<<arr[l-1]<<" "<<have[0]<<'\n';
Answer(arr[l-1],have[0]);
return;
}
int mid=(l+r)>>1,last;
vector<int>L,R;
for (int i=l-1;i<mid;i++)
last=Query(arr[i]);
for (auto i:have){
int now=Query(i);
if (now==last)
L.push_back(i);
else R.push_back(i);
Query(i);
}
Merge(mid+1,r,R);
for (int i=l-1;i<mid;i++)
Query(arr[i]);
Merge(l,mid,L);
}
void Solve(int N){
vector<int>qry;
int last=-1;
for (int i=1;i<=2*N;i++){
int now=Query(i);
if (now==last){
Query(i);
qry.push_back(i);
}
else {
arr.push_back(i);
last=now;
}
}
for (int i=1;i<=N;i++)
Query(arr[i-1]);
//for (auto i:arr) cout<<i<<" ";
//cout<<'\n';
//for (auto i:qry) cout<<i<<" ";
//cout<<'\n';
Merge(1,N,qry);
}
/*
g++ -std=gnu++14 -O2 -o grader grader.cpp minerals.cpp
./grader.exe
4
1 5
2 6
3 4
7 8
*/
Compilation message
minerals.cpp: In function 'void Merge(int, int, std::vector<int>)':
minerals.cpp:18:9: warning: 'last' may be used uninitialized in this function [-Wmaybe-uninitialized]
18 | if (now==last)
| ^~
# |
결과 |
실행 시간 |
메모리 |
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 |
436 KB |
Output is correct |
4 |
Correct |
7 ms |
720 KB |
Output is correct |
5 |
Correct |
13 ms |
976 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 |
436 KB |
Output is correct |
8 |
Correct |
7 ms |
720 KB |
Output is correct |
9 |
Correct |
13 ms |
976 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
9 ms |
904 KB |
Output is correct |
12 |
Correct |
13 ms |
1112 KB |
Output is correct |
13 |
Correct |
12 ms |
1088 KB |
Output is correct |
14 |
Correct |
12 ms |
1008 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 |
436 KB |
Output is correct |
8 |
Correct |
7 ms |
720 KB |
Output is correct |
9 |
Correct |
13 ms |
976 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
9 ms |
904 KB |
Output is correct |
12 |
Correct |
13 ms |
1112 KB |
Output is correct |
13 |
Correct |
12 ms |
1088 KB |
Output is correct |
14 |
Correct |
12 ms |
1008 KB |
Output is correct |
15 |
Incorrect |
22 ms |
2260 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
436 KB |
Output is correct |
8 |
Correct |
7 ms |
720 KB |
Output is correct |
9 |
Correct |
13 ms |
976 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
9 ms |
904 KB |
Output is correct |
12 |
Correct |
13 ms |
1112 KB |
Output is correct |
13 |
Correct |
12 ms |
1088 KB |
Output is correct |
14 |
Correct |
12 ms |
1008 KB |
Output is correct |
15 |
Incorrect |
22 ms |
2260 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
436 KB |
Output is correct |
8 |
Correct |
7 ms |
720 KB |
Output is correct |
9 |
Correct |
13 ms |
976 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
9 ms |
904 KB |
Output is correct |
12 |
Correct |
13 ms |
1112 KB |
Output is correct |
13 |
Correct |
12 ms |
1088 KB |
Output is correct |
14 |
Correct |
12 ms |
1008 KB |
Output is correct |
15 |
Incorrect |
22 ms |
2260 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
436 KB |
Output is correct |
8 |
Correct |
7 ms |
720 KB |
Output is correct |
9 |
Correct |
13 ms |
976 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
9 ms |
904 KB |
Output is correct |
12 |
Correct |
13 ms |
1112 KB |
Output is correct |
13 |
Correct |
12 ms |
1088 KB |
Output is correct |
14 |
Correct |
12 ms |
1008 KB |
Output is correct |
15 |
Incorrect |
22 ms |
2260 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
436 KB |
Output is correct |
8 |
Correct |
7 ms |
720 KB |
Output is correct |
9 |
Correct |
13 ms |
976 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
9 ms |
904 KB |
Output is correct |
12 |
Correct |
13 ms |
1112 KB |
Output is correct |
13 |
Correct |
12 ms |
1088 KB |
Output is correct |
14 |
Correct |
12 ms |
1008 KB |
Output is correct |
15 |
Incorrect |
22 ms |
2260 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
436 KB |
Output is correct |
8 |
Correct |
7 ms |
720 KB |
Output is correct |
9 |
Correct |
13 ms |
976 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
9 ms |
904 KB |
Output is correct |
12 |
Correct |
13 ms |
1112 KB |
Output is correct |
13 |
Correct |
12 ms |
1088 KB |
Output is correct |
14 |
Correct |
12 ms |
1008 KB |
Output is correct |
15 |
Incorrect |
22 ms |
2260 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |