#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 45005;
int lst = 0;
bool In[2 * MAXN];
vector <int> A, B;
void Solve(int n)
{
for(int i = 1; i <= 2 * n; i++)
{
int cur = Query(i);
In[i] ^= 1;
if(cur == lst)
{
B.push_back(i);
}
else
{
A.push_back(i);
}
lst = cur;
}
vector <pair <int, int> > BFS;
BFS.emplace_back(0, n - 1);
for(int times = 1; times <= 16; times++)
{
vector <pair <int, int> > NextLayer;
// for(auto x : B)
// {
// cout << x << ' ';
// }
// cout << '\n';
for(auto x : BFS)
{
int mid = (x.first + x.second) >> 1;
// cout << x.first << ' ' << mid << ' ' << mid + 1 << ' ' << x.second << '\n';
if(x.first < x.second)
{
NextLayer.emplace_back(x.first, mid);
NextLayer.emplace_back(mid + 1, x.second);
// for(int i = 1; i <= 2 * n; i++)
// {
// cout << In[i] << ' ';
// }
// cout << '\n';
if(In[A[mid + 1]])
{
for(int i = mid + 1; i <= x.second; i++)
{
assert(In[A[i]]);
lst = Query(A[i]);
In[A[i]] ^= 1;
}
}
// cout << "owo" << endl;
if(!In[A[x.first]])
{
for(int i = x.first; i <= mid; i++)
{
assert(!In[A[i]]);
lst = Query(A[i]);
In[A[i]] ^= 1;
}
}
// for(int i = 1; i <= 2 * n; i++)
// {
// cout << In[i] << ' ';
// }
// cout << '\n';
vector <int> L, R;
if(In[B[x.first]])
{
for(int i = x.first; i <= x.second; i++)
{
assert(In[B[i]]);
int tmp = Query(B[i]);
In[B[i]] ^= 1;
if(tmp == lst)
{
L.push_back(B[i]);
}
else
{
R.push_back(B[i]);
}
lst = tmp;
}
}
else
{
for(int i = x.first; i <= x.second; i++)
{
assert(!In[B[i]]);
int tmp = Query(B[i]);
In[B[i]] ^= 1;
if(tmp == lst)
{
L.push_back(B[i]);
}
else
{
R.push_back(B[i]);
}
lst = tmp;
}
}
// cout << L.size() << ' ' << R.size() << '\n';
for(int i = x.first; i <= mid; i++)
{
B[i] = L[i - x.first];
}
for(int i = mid + 1; i <= x.second; i++)
{
B[i] = R[i - mid - 1];
}
}
else
{
if(In[A[x.first]])
{
Query(A[x.first]);
In[A[x.first]] ^= 1;
}
}
}
BFS.swap(NextLayer);
}
for(int i = 0; i < n; i++)
{
Answer(A[i], B[i]);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
2 ms |
328 KB |
Output is correct |
3 |
Correct |
3 ms |
456 KB |
Output is correct |
4 |
Correct |
6 ms |
740 KB |
Output is correct |
5 |
Correct |
12 ms |
1052 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
456 KB |
Output is correct |
8 |
Correct |
6 ms |
740 KB |
Output is correct |
9 |
Correct |
12 ms |
1052 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
8 ms |
840 KB |
Output is correct |
12 |
Correct |
11 ms |
1064 KB |
Output is correct |
13 |
Correct |
10 ms |
1112 KB |
Output is correct |
14 |
Correct |
10 ms |
1116 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
456 KB |
Output is correct |
8 |
Correct |
6 ms |
740 KB |
Output is correct |
9 |
Correct |
12 ms |
1052 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
8 ms |
840 KB |
Output is correct |
12 |
Correct |
11 ms |
1064 KB |
Output is correct |
13 |
Correct |
10 ms |
1112 KB |
Output is correct |
14 |
Correct |
10 ms |
1116 KB |
Output is correct |
15 |
Correct |
36 ms |
2348 KB |
Output is correct |
16 |
Correct |
38 ms |
2336 KB |
Output is correct |
17 |
Correct |
30 ms |
2264 KB |
Output is correct |
18 |
Correct |
26 ms |
2100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
456 KB |
Output is correct |
8 |
Correct |
6 ms |
740 KB |
Output is correct |
9 |
Correct |
12 ms |
1052 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
8 ms |
840 KB |
Output is correct |
12 |
Correct |
11 ms |
1064 KB |
Output is correct |
13 |
Correct |
10 ms |
1112 KB |
Output is correct |
14 |
Correct |
10 ms |
1116 KB |
Output is correct |
15 |
Correct |
36 ms |
2348 KB |
Output is correct |
16 |
Correct |
38 ms |
2336 KB |
Output is correct |
17 |
Correct |
30 ms |
2264 KB |
Output is correct |
18 |
Correct |
26 ms |
2100 KB |
Output is correct |
19 |
Correct |
35 ms |
2388 KB |
Output is correct |
20 |
Correct |
35 ms |
2344 KB |
Output is correct |
21 |
Correct |
29 ms |
2304 KB |
Output is correct |
22 |
Correct |
28 ms |
2132 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
456 KB |
Output is correct |
8 |
Correct |
6 ms |
740 KB |
Output is correct |
9 |
Correct |
12 ms |
1052 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
8 ms |
840 KB |
Output is correct |
12 |
Correct |
11 ms |
1064 KB |
Output is correct |
13 |
Correct |
10 ms |
1112 KB |
Output is correct |
14 |
Correct |
10 ms |
1116 KB |
Output is correct |
15 |
Correct |
36 ms |
2348 KB |
Output is correct |
16 |
Correct |
38 ms |
2336 KB |
Output is correct |
17 |
Correct |
30 ms |
2264 KB |
Output is correct |
18 |
Correct |
26 ms |
2100 KB |
Output is correct |
19 |
Correct |
35 ms |
2388 KB |
Output is correct |
20 |
Correct |
35 ms |
2344 KB |
Output is correct |
21 |
Correct |
29 ms |
2304 KB |
Output is correct |
22 |
Correct |
28 ms |
2132 KB |
Output is correct |
23 |
Incorrect |
36 ms |
2340 KB |
Wrong Answer [2] |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
456 KB |
Output is correct |
8 |
Correct |
6 ms |
740 KB |
Output is correct |
9 |
Correct |
12 ms |
1052 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
8 ms |
840 KB |
Output is correct |
12 |
Correct |
11 ms |
1064 KB |
Output is correct |
13 |
Correct |
10 ms |
1112 KB |
Output is correct |
14 |
Correct |
10 ms |
1116 KB |
Output is correct |
15 |
Correct |
36 ms |
2348 KB |
Output is correct |
16 |
Correct |
38 ms |
2336 KB |
Output is correct |
17 |
Correct |
30 ms |
2264 KB |
Output is correct |
18 |
Correct |
26 ms |
2100 KB |
Output is correct |
19 |
Correct |
35 ms |
2388 KB |
Output is correct |
20 |
Correct |
35 ms |
2344 KB |
Output is correct |
21 |
Correct |
29 ms |
2304 KB |
Output is correct |
22 |
Correct |
28 ms |
2132 KB |
Output is correct |
23 |
Incorrect |
36 ms |
2340 KB |
Wrong Answer [2] |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
456 KB |
Output is correct |
8 |
Correct |
6 ms |
740 KB |
Output is correct |
9 |
Correct |
12 ms |
1052 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
8 ms |
840 KB |
Output is correct |
12 |
Correct |
11 ms |
1064 KB |
Output is correct |
13 |
Correct |
10 ms |
1112 KB |
Output is correct |
14 |
Correct |
10 ms |
1116 KB |
Output is correct |
15 |
Correct |
36 ms |
2348 KB |
Output is correct |
16 |
Correct |
38 ms |
2336 KB |
Output is correct |
17 |
Correct |
30 ms |
2264 KB |
Output is correct |
18 |
Correct |
26 ms |
2100 KB |
Output is correct |
19 |
Correct |
35 ms |
2388 KB |
Output is correct |
20 |
Correct |
35 ms |
2344 KB |
Output is correct |
21 |
Correct |
29 ms |
2304 KB |
Output is correct |
22 |
Correct |
28 ms |
2132 KB |
Output is correct |
23 |
Incorrect |
36 ms |
2340 KB |
Wrong Answer [2] |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
328 KB |
Output is correct |
7 |
Correct |
3 ms |
456 KB |
Output is correct |
8 |
Correct |
6 ms |
740 KB |
Output is correct |
9 |
Correct |
12 ms |
1052 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
8 ms |
840 KB |
Output is correct |
12 |
Correct |
11 ms |
1064 KB |
Output is correct |
13 |
Correct |
10 ms |
1112 KB |
Output is correct |
14 |
Correct |
10 ms |
1116 KB |
Output is correct |
15 |
Correct |
36 ms |
2348 KB |
Output is correct |
16 |
Correct |
38 ms |
2336 KB |
Output is correct |
17 |
Correct |
30 ms |
2264 KB |
Output is correct |
18 |
Correct |
26 ms |
2100 KB |
Output is correct |
19 |
Correct |
35 ms |
2388 KB |
Output is correct |
20 |
Correct |
35 ms |
2344 KB |
Output is correct |
21 |
Correct |
29 ms |
2304 KB |
Output is correct |
22 |
Correct |
28 ms |
2132 KB |
Output is correct |
23 |
Incorrect |
36 ms |
2340 KB |
Wrong Answer [2] |
24 |
Halted |
0 ms |
0 KB |
- |