#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
const int nx=5e4+5;
int n, p, c, l[nx], r[nx];
vector<int> used, v, qrs[nx];
void Solve(int N) {
v.push_back(0);
used.push_back(0);
for (int i=1; i<=2*N; i++)
{
c=Query(i);
if (c==p) v.push_back(i);
else used.push_back(i), p=c;
}
for (int i=1; i<=2*N; i++) Query(i);
for (int i=1; i<=N; i++) l[i]=1, r[i]=N;
while (1)
{
bool f=1;
//cout<<"bsearch\n";
//for (int i=1; i<=N; i++) cout<<i<<' '<<l[i]<<' '<<r[i]<<'\n';
for (int i=1; i<=N; i++) qrs[i].clear();
for (int i=1; i<=N; i++) if (l[i]!=r[i]) f=0, qrs[(l[i]+r[i])/2].push_back(i);
if (f) break;
for (int i=1; i<=N; i++)
{
p=Query(used[i]);
for (auto x:qrs[i])
{
c=Query(v[x]);
if (c==p) r[x]=i;
else l[x]=i+1;
p=Query(v[x]);
}
}
for (int i=1; i<=N; i++) Query(used[i]);
}
for (int i=1; i<=N; i++) Answer(v[i], used[l[i]]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
0 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2648 KB |
Output is correct |
3 |
Correct |
3 ms |
2904 KB |
Output is correct |
4 |
Correct |
6 ms |
3240 KB |
Output is correct |
5 |
Correct |
11 ms |
4184 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
0 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2904 KB |
Output is correct |
8 |
Correct |
6 ms |
3240 KB |
Output is correct |
9 |
Correct |
11 ms |
4184 KB |
Output is correct |
10 |
Correct |
2 ms |
2648 KB |
Output is correct |
11 |
Correct |
8 ms |
3764 KB |
Output is correct |
12 |
Correct |
11 ms |
4060 KB |
Output is correct |
13 |
Correct |
8 ms |
4184 KB |
Output is correct |
14 |
Correct |
8 ms |
4184 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
0 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2904 KB |
Output is correct |
8 |
Correct |
6 ms |
3240 KB |
Output is correct |
9 |
Correct |
11 ms |
4184 KB |
Output is correct |
10 |
Correct |
2 ms |
2648 KB |
Output is correct |
11 |
Correct |
8 ms |
3764 KB |
Output is correct |
12 |
Correct |
11 ms |
4060 KB |
Output is correct |
13 |
Correct |
8 ms |
4184 KB |
Output is correct |
14 |
Correct |
8 ms |
4184 KB |
Output is correct |
15 |
Incorrect |
14 ms |
4828 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
0 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2904 KB |
Output is correct |
8 |
Correct |
6 ms |
3240 KB |
Output is correct |
9 |
Correct |
11 ms |
4184 KB |
Output is correct |
10 |
Correct |
2 ms |
2648 KB |
Output is correct |
11 |
Correct |
8 ms |
3764 KB |
Output is correct |
12 |
Correct |
11 ms |
4060 KB |
Output is correct |
13 |
Correct |
8 ms |
4184 KB |
Output is correct |
14 |
Correct |
8 ms |
4184 KB |
Output is correct |
15 |
Incorrect |
14 ms |
4828 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
0 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2904 KB |
Output is correct |
8 |
Correct |
6 ms |
3240 KB |
Output is correct |
9 |
Correct |
11 ms |
4184 KB |
Output is correct |
10 |
Correct |
2 ms |
2648 KB |
Output is correct |
11 |
Correct |
8 ms |
3764 KB |
Output is correct |
12 |
Correct |
11 ms |
4060 KB |
Output is correct |
13 |
Correct |
8 ms |
4184 KB |
Output is correct |
14 |
Correct |
8 ms |
4184 KB |
Output is correct |
15 |
Incorrect |
14 ms |
4828 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
0 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2904 KB |
Output is correct |
8 |
Correct |
6 ms |
3240 KB |
Output is correct |
9 |
Correct |
11 ms |
4184 KB |
Output is correct |
10 |
Correct |
2 ms |
2648 KB |
Output is correct |
11 |
Correct |
8 ms |
3764 KB |
Output is correct |
12 |
Correct |
11 ms |
4060 KB |
Output is correct |
13 |
Correct |
8 ms |
4184 KB |
Output is correct |
14 |
Correct |
8 ms |
4184 KB |
Output is correct |
15 |
Incorrect |
14 ms |
4828 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
0 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2904 KB |
Output is correct |
8 |
Correct |
6 ms |
3240 KB |
Output is correct |
9 |
Correct |
11 ms |
4184 KB |
Output is correct |
10 |
Correct |
2 ms |
2648 KB |
Output is correct |
11 |
Correct |
8 ms |
3764 KB |
Output is correct |
12 |
Correct |
11 ms |
4060 KB |
Output is correct |
13 |
Correct |
8 ms |
4184 KB |
Output is correct |
14 |
Correct |
8 ms |
4184 KB |
Output is correct |
15 |
Incorrect |
14 ms |
4828 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
0 ms |
2648 KB |
Output is correct |
3 |
Correct |
1 ms |
2648 KB |
Output is correct |
4 |
Correct |
1 ms |
2648 KB |
Output is correct |
5 |
Correct |
1 ms |
2648 KB |
Output is correct |
6 |
Correct |
1 ms |
2648 KB |
Output is correct |
7 |
Correct |
3 ms |
2904 KB |
Output is correct |
8 |
Correct |
6 ms |
3240 KB |
Output is correct |
9 |
Correct |
11 ms |
4184 KB |
Output is correct |
10 |
Correct |
2 ms |
2648 KB |
Output is correct |
11 |
Correct |
8 ms |
3764 KB |
Output is correct |
12 |
Correct |
11 ms |
4060 KB |
Output is correct |
13 |
Correct |
8 ms |
4184 KB |
Output is correct |
14 |
Correct |
8 ms |
4184 KB |
Output is correct |
15 |
Incorrect |
14 ms |
4828 KB |
Wrong Answer [2] |
16 |
Halted |
0 ms |
0 KB |
- |