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