#include <bits/stdc++.h>
#include "minerals.h"
//~ #include "grader.cpp"
using namespace std;
set <int> active;
vector <int> s, e;
int curl, curr;
int curq;
int query(int x){
if(active.count(x)) active.erase(x);
else active.insert(x);
return curq = Query(x);
}
void solve(int l, int r, vector <int> &cur){
if(r < l) return;
if(l == r){
assert(cur.size() == 1);
Answer(e[l], cur[0]);
return;
}
int mid = (l + r - 1) / 2;
for(int i = l ; i <= mid ; i++){
if(active.count(e[i])) continue;
query(e[i]);
}
for(int i = mid + 1 ; i <= r ; i++){
if(!active.count(e[i])) continue;
query(e[i]);
}
vector <int> left, right;
for(int i = 0 ; i < (int)cur.size() - 1 ; i++){
int las = curq;
query(cur[i]);
if(curq == las) left.push_back(cur[i]);
else right.push_back(cur[i]);
}
if((int)left.size() != mid - l + 1) left.push_back(cur.back());
else right.push_back(cur.back());
solve(l, mid, left);
solve(mid + 1, r, right);
}
void Solve(int N){
for(int i = 1 ; i <= 2 * N ; i++){
int prev = curq;
query(i);
if(curq != prev) s.push_back(i);
else e.push_back(i);
}
curl = 0;
curr = N - 1;
solve(0, N - 1, s);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
504 KB |
Output is correct |
2 |
Correct |
9 ms |
632 KB |
Output is correct |
3 |
Correct |
20 ms |
760 KB |
Output is correct |
4 |
Correct |
42 ms |
1272 KB |
Output is correct |
5 |
Correct |
98 ms |
2168 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
504 KB |
Output is correct |
6 |
Correct |
9 ms |
632 KB |
Output is correct |
7 |
Correct |
20 ms |
760 KB |
Output is correct |
8 |
Correct |
42 ms |
1272 KB |
Output is correct |
9 |
Correct |
98 ms |
2168 KB |
Output is correct |
10 |
Correct |
6 ms |
376 KB |
Output is correct |
11 |
Correct |
64 ms |
1656 KB |
Output is correct |
12 |
Correct |
107 ms |
2400 KB |
Output is correct |
13 |
Correct |
80 ms |
2296 KB |
Output is correct |
14 |
Correct |
71 ms |
2180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
504 KB |
Output is correct |
6 |
Correct |
9 ms |
632 KB |
Output is correct |
7 |
Correct |
20 ms |
760 KB |
Output is correct |
8 |
Correct |
42 ms |
1272 KB |
Output is correct |
9 |
Correct |
98 ms |
2168 KB |
Output is correct |
10 |
Correct |
6 ms |
376 KB |
Output is correct |
11 |
Correct |
64 ms |
1656 KB |
Output is correct |
12 |
Correct |
107 ms |
2400 KB |
Output is correct |
13 |
Correct |
80 ms |
2296 KB |
Output is correct |
14 |
Correct |
71 ms |
2180 KB |
Output is correct |
15 |
Correct |
321 ms |
5620 KB |
Output is correct |
16 |
Correct |
335 ms |
5776 KB |
Output is correct |
17 |
Correct |
232 ms |
5616 KB |
Output is correct |
18 |
Correct |
211 ms |
4860 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
504 KB |
Output is correct |
6 |
Correct |
9 ms |
632 KB |
Output is correct |
7 |
Correct |
20 ms |
760 KB |
Output is correct |
8 |
Correct |
42 ms |
1272 KB |
Output is correct |
9 |
Correct |
98 ms |
2168 KB |
Output is correct |
10 |
Correct |
6 ms |
376 KB |
Output is correct |
11 |
Correct |
64 ms |
1656 KB |
Output is correct |
12 |
Correct |
107 ms |
2400 KB |
Output is correct |
13 |
Correct |
80 ms |
2296 KB |
Output is correct |
14 |
Correct |
71 ms |
2180 KB |
Output is correct |
15 |
Correct |
321 ms |
5620 KB |
Output is correct |
16 |
Correct |
335 ms |
5776 KB |
Output is correct |
17 |
Correct |
232 ms |
5616 KB |
Output is correct |
18 |
Correct |
211 ms |
4860 KB |
Output is correct |
19 |
Correct |
357 ms |
5924 KB |
Output is correct |
20 |
Correct |
338 ms |
5912 KB |
Output is correct |
21 |
Correct |
240 ms |
5904 KB |
Output is correct |
22 |
Correct |
221 ms |
4980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
504 KB |
Output is correct |
6 |
Correct |
9 ms |
632 KB |
Output is correct |
7 |
Correct |
20 ms |
760 KB |
Output is correct |
8 |
Correct |
42 ms |
1272 KB |
Output is correct |
9 |
Correct |
98 ms |
2168 KB |
Output is correct |
10 |
Correct |
6 ms |
376 KB |
Output is correct |
11 |
Correct |
64 ms |
1656 KB |
Output is correct |
12 |
Correct |
107 ms |
2400 KB |
Output is correct |
13 |
Correct |
80 ms |
2296 KB |
Output is correct |
14 |
Correct |
71 ms |
2180 KB |
Output is correct |
15 |
Correct |
321 ms |
5620 KB |
Output is correct |
16 |
Correct |
335 ms |
5776 KB |
Output is correct |
17 |
Correct |
232 ms |
5616 KB |
Output is correct |
18 |
Correct |
211 ms |
4860 KB |
Output is correct |
19 |
Correct |
357 ms |
5924 KB |
Output is correct |
20 |
Correct |
338 ms |
5912 KB |
Output is correct |
21 |
Correct |
240 ms |
5904 KB |
Output is correct |
22 |
Correct |
221 ms |
4980 KB |
Output is correct |
23 |
Correct |
365 ms |
6072 KB |
Output is correct |
24 |
Correct |
341 ms |
5924 KB |
Output is correct |
25 |
Correct |
246 ms |
5872 KB |
Output is correct |
26 |
Correct |
222 ms |
5108 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
504 KB |
Output is correct |
6 |
Correct |
9 ms |
632 KB |
Output is correct |
7 |
Correct |
20 ms |
760 KB |
Output is correct |
8 |
Correct |
42 ms |
1272 KB |
Output is correct |
9 |
Correct |
98 ms |
2168 KB |
Output is correct |
10 |
Correct |
6 ms |
376 KB |
Output is correct |
11 |
Correct |
64 ms |
1656 KB |
Output is correct |
12 |
Correct |
107 ms |
2400 KB |
Output is correct |
13 |
Correct |
80 ms |
2296 KB |
Output is correct |
14 |
Correct |
71 ms |
2180 KB |
Output is correct |
15 |
Correct |
321 ms |
5620 KB |
Output is correct |
16 |
Correct |
335 ms |
5776 KB |
Output is correct |
17 |
Correct |
232 ms |
5616 KB |
Output is correct |
18 |
Correct |
211 ms |
4860 KB |
Output is correct |
19 |
Correct |
357 ms |
5924 KB |
Output is correct |
20 |
Correct |
338 ms |
5912 KB |
Output is correct |
21 |
Correct |
240 ms |
5904 KB |
Output is correct |
22 |
Correct |
221 ms |
4980 KB |
Output is correct |
23 |
Correct |
365 ms |
6072 KB |
Output is correct |
24 |
Correct |
341 ms |
5924 KB |
Output is correct |
25 |
Correct |
246 ms |
5872 KB |
Output is correct |
26 |
Correct |
222 ms |
5108 KB |
Output is correct |
27 |
Correct |
360 ms |
6036 KB |
Output is correct |
28 |
Correct |
363 ms |
6068 KB |
Output is correct |
29 |
Correct |
261 ms |
6052 KB |
Output is correct |
30 |
Correct |
229 ms |
5364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
504 KB |
Output is correct |
6 |
Correct |
9 ms |
632 KB |
Output is correct |
7 |
Correct |
20 ms |
760 KB |
Output is correct |
8 |
Correct |
42 ms |
1272 KB |
Output is correct |
9 |
Correct |
98 ms |
2168 KB |
Output is correct |
10 |
Correct |
6 ms |
376 KB |
Output is correct |
11 |
Correct |
64 ms |
1656 KB |
Output is correct |
12 |
Correct |
107 ms |
2400 KB |
Output is correct |
13 |
Correct |
80 ms |
2296 KB |
Output is correct |
14 |
Correct |
71 ms |
2180 KB |
Output is correct |
15 |
Correct |
321 ms |
5620 KB |
Output is correct |
16 |
Correct |
335 ms |
5776 KB |
Output is correct |
17 |
Correct |
232 ms |
5616 KB |
Output is correct |
18 |
Correct |
211 ms |
4860 KB |
Output is correct |
19 |
Correct |
357 ms |
5924 KB |
Output is correct |
20 |
Correct |
338 ms |
5912 KB |
Output is correct |
21 |
Correct |
240 ms |
5904 KB |
Output is correct |
22 |
Correct |
221 ms |
4980 KB |
Output is correct |
23 |
Correct |
365 ms |
6072 KB |
Output is correct |
24 |
Correct |
341 ms |
5924 KB |
Output is correct |
25 |
Correct |
246 ms |
5872 KB |
Output is correct |
26 |
Correct |
222 ms |
5108 KB |
Output is correct |
27 |
Correct |
360 ms |
6036 KB |
Output is correct |
28 |
Correct |
363 ms |
6068 KB |
Output is correct |
29 |
Correct |
261 ms |
6052 KB |
Output is correct |
30 |
Correct |
229 ms |
5364 KB |
Output is correct |
31 |
Incorrect |
372 ms |
6320 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
504 KB |
Output is correct |
6 |
Correct |
9 ms |
632 KB |
Output is correct |
7 |
Correct |
20 ms |
760 KB |
Output is correct |
8 |
Correct |
42 ms |
1272 KB |
Output is correct |
9 |
Correct |
98 ms |
2168 KB |
Output is correct |
10 |
Correct |
6 ms |
376 KB |
Output is correct |
11 |
Correct |
64 ms |
1656 KB |
Output is correct |
12 |
Correct |
107 ms |
2400 KB |
Output is correct |
13 |
Correct |
80 ms |
2296 KB |
Output is correct |
14 |
Correct |
71 ms |
2180 KB |
Output is correct |
15 |
Correct |
321 ms |
5620 KB |
Output is correct |
16 |
Correct |
335 ms |
5776 KB |
Output is correct |
17 |
Correct |
232 ms |
5616 KB |
Output is correct |
18 |
Correct |
211 ms |
4860 KB |
Output is correct |
19 |
Correct |
357 ms |
5924 KB |
Output is correct |
20 |
Correct |
338 ms |
5912 KB |
Output is correct |
21 |
Correct |
240 ms |
5904 KB |
Output is correct |
22 |
Correct |
221 ms |
4980 KB |
Output is correct |
23 |
Correct |
365 ms |
6072 KB |
Output is correct |
24 |
Correct |
341 ms |
5924 KB |
Output is correct |
25 |
Correct |
246 ms |
5872 KB |
Output is correct |
26 |
Correct |
222 ms |
5108 KB |
Output is correct |
27 |
Correct |
360 ms |
6036 KB |
Output is correct |
28 |
Correct |
363 ms |
6068 KB |
Output is correct |
29 |
Correct |
261 ms |
6052 KB |
Output is correct |
30 |
Correct |
229 ms |
5364 KB |
Output is correct |
31 |
Incorrect |
372 ms |
6320 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |