#include "minerals.h"
#include <bits/stdc++.h>
using namespace std;
int n;
int cur = 0;
int isbase[90000];
set<int> taken;
bool in(int i){
return (taken.find(i) != taken.end());
}
int query(int i){
if(!in(i)) taken.insert(i);
else taken.erase(i);
cur = Query(i);
return cur;
}
vector<int> base;
vector<int> other;
int otherVal[90000];
void modifyBase(int bit){
for(int i = 0;i < n;i++){
if((i & (1 << bit)) == 0){
if(!in(base[i])) query(base[i]);
}
else{
if(in(base[i])) query(base[i]);
}
}
//cout << bit << ": ";
//for(int x : taken) cout << x << " ";
//cout << "\n";
}
bool check(int i){
int pre = cur;
int x = other[i];
query(x);
if(cur == pre) return true;
else return false;
return true;
}
void Solve(int N){
n = N;
for(int i = 1;i <= 2*n;i++){
int pre = cur;
int C = query(i);
if(pre == C) isbase[i] = 0;
else isbase[i] = 1;
if(isbase[i]) base.push_back(i);
else other.push_back(i);
}
int bit = 0;
while((1<< bit) < n) bit++;
bit--;
for(;bit >= 0;bit--){
modifyBase(bit);
for(int i = 0;i < n;i++){
if(otherVal[i] + (1<<bit) >= n) continue;
if(!check(i)){
otherVal[i] += (1 << bit);
}
}
}
for(int i = 0;i < n;i++){
int B = base[otherVal[i]];
int O = other[i];
//cout << B << " " << O << "\n";
Answer(B, O);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
512 KB |
Output is correct |
2 |
Correct |
8 ms |
640 KB |
Output is correct |
3 |
Correct |
14 ms |
928 KB |
Output is correct |
4 |
Correct |
30 ms |
1408 KB |
Output is correct |
5 |
Correct |
70 ms |
2424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
8 ms |
640 KB |
Output is correct |
7 |
Correct |
14 ms |
928 KB |
Output is correct |
8 |
Correct |
30 ms |
1408 KB |
Output is correct |
9 |
Correct |
70 ms |
2424 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
50 ms |
1784 KB |
Output is correct |
12 |
Correct |
81 ms |
2552 KB |
Output is correct |
13 |
Correct |
75 ms |
2552 KB |
Output is correct |
14 |
Correct |
64 ms |
2424 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
8 ms |
640 KB |
Output is correct |
7 |
Correct |
14 ms |
928 KB |
Output is correct |
8 |
Correct |
30 ms |
1408 KB |
Output is correct |
9 |
Correct |
70 ms |
2424 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
50 ms |
1784 KB |
Output is correct |
12 |
Correct |
81 ms |
2552 KB |
Output is correct |
13 |
Correct |
75 ms |
2552 KB |
Output is correct |
14 |
Correct |
64 ms |
2424 KB |
Output is correct |
15 |
Correct |
230 ms |
5876 KB |
Output is correct |
16 |
Correct |
231 ms |
5876 KB |
Output is correct |
17 |
Correct |
222 ms |
5844 KB |
Output is correct |
18 |
Correct |
200 ms |
5792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
8 ms |
640 KB |
Output is correct |
7 |
Correct |
14 ms |
928 KB |
Output is correct |
8 |
Correct |
30 ms |
1408 KB |
Output is correct |
9 |
Correct |
70 ms |
2424 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
50 ms |
1784 KB |
Output is correct |
12 |
Correct |
81 ms |
2552 KB |
Output is correct |
13 |
Correct |
75 ms |
2552 KB |
Output is correct |
14 |
Correct |
64 ms |
2424 KB |
Output is correct |
15 |
Correct |
230 ms |
5876 KB |
Output is correct |
16 |
Correct |
231 ms |
5876 KB |
Output is correct |
17 |
Correct |
222 ms |
5844 KB |
Output is correct |
18 |
Correct |
200 ms |
5792 KB |
Output is correct |
19 |
Correct |
230 ms |
5996 KB |
Output is correct |
20 |
Correct |
231 ms |
6004 KB |
Output is correct |
21 |
Correct |
230 ms |
6000 KB |
Output is correct |
22 |
Correct |
204 ms |
5964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
8 ms |
640 KB |
Output is correct |
7 |
Correct |
14 ms |
928 KB |
Output is correct |
8 |
Correct |
30 ms |
1408 KB |
Output is correct |
9 |
Correct |
70 ms |
2424 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
50 ms |
1784 KB |
Output is correct |
12 |
Correct |
81 ms |
2552 KB |
Output is correct |
13 |
Correct |
75 ms |
2552 KB |
Output is correct |
14 |
Correct |
64 ms |
2424 KB |
Output is correct |
15 |
Correct |
230 ms |
5876 KB |
Output is correct |
16 |
Correct |
231 ms |
5876 KB |
Output is correct |
17 |
Correct |
222 ms |
5844 KB |
Output is correct |
18 |
Correct |
200 ms |
5792 KB |
Output is correct |
19 |
Correct |
230 ms |
5996 KB |
Output is correct |
20 |
Correct |
231 ms |
6004 KB |
Output is correct |
21 |
Correct |
230 ms |
6000 KB |
Output is correct |
22 |
Correct |
204 ms |
5964 KB |
Output is correct |
23 |
Incorrect |
240 ms |
5880 KB |
Wrong Answer [2] |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
8 ms |
640 KB |
Output is correct |
7 |
Correct |
14 ms |
928 KB |
Output is correct |
8 |
Correct |
30 ms |
1408 KB |
Output is correct |
9 |
Correct |
70 ms |
2424 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
50 ms |
1784 KB |
Output is correct |
12 |
Correct |
81 ms |
2552 KB |
Output is correct |
13 |
Correct |
75 ms |
2552 KB |
Output is correct |
14 |
Correct |
64 ms |
2424 KB |
Output is correct |
15 |
Correct |
230 ms |
5876 KB |
Output is correct |
16 |
Correct |
231 ms |
5876 KB |
Output is correct |
17 |
Correct |
222 ms |
5844 KB |
Output is correct |
18 |
Correct |
200 ms |
5792 KB |
Output is correct |
19 |
Correct |
230 ms |
5996 KB |
Output is correct |
20 |
Correct |
231 ms |
6004 KB |
Output is correct |
21 |
Correct |
230 ms |
6000 KB |
Output is correct |
22 |
Correct |
204 ms |
5964 KB |
Output is correct |
23 |
Incorrect |
240 ms |
5880 KB |
Wrong Answer [2] |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
8 ms |
640 KB |
Output is correct |
7 |
Correct |
14 ms |
928 KB |
Output is correct |
8 |
Correct |
30 ms |
1408 KB |
Output is correct |
9 |
Correct |
70 ms |
2424 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
50 ms |
1784 KB |
Output is correct |
12 |
Correct |
81 ms |
2552 KB |
Output is correct |
13 |
Correct |
75 ms |
2552 KB |
Output is correct |
14 |
Correct |
64 ms |
2424 KB |
Output is correct |
15 |
Correct |
230 ms |
5876 KB |
Output is correct |
16 |
Correct |
231 ms |
5876 KB |
Output is correct |
17 |
Correct |
222 ms |
5844 KB |
Output is correct |
18 |
Correct |
200 ms |
5792 KB |
Output is correct |
19 |
Correct |
230 ms |
5996 KB |
Output is correct |
20 |
Correct |
231 ms |
6004 KB |
Output is correct |
21 |
Correct |
230 ms |
6000 KB |
Output is correct |
22 |
Correct |
204 ms |
5964 KB |
Output is correct |
23 |
Incorrect |
240 ms |
5880 KB |
Wrong Answer [2] |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
512 KB |
Output is correct |
6 |
Correct |
8 ms |
640 KB |
Output is correct |
7 |
Correct |
14 ms |
928 KB |
Output is correct |
8 |
Correct |
30 ms |
1408 KB |
Output is correct |
9 |
Correct |
70 ms |
2424 KB |
Output is correct |
10 |
Correct |
4 ms |
512 KB |
Output is correct |
11 |
Correct |
50 ms |
1784 KB |
Output is correct |
12 |
Correct |
81 ms |
2552 KB |
Output is correct |
13 |
Correct |
75 ms |
2552 KB |
Output is correct |
14 |
Correct |
64 ms |
2424 KB |
Output is correct |
15 |
Correct |
230 ms |
5876 KB |
Output is correct |
16 |
Correct |
231 ms |
5876 KB |
Output is correct |
17 |
Correct |
222 ms |
5844 KB |
Output is correct |
18 |
Correct |
200 ms |
5792 KB |
Output is correct |
19 |
Correct |
230 ms |
5996 KB |
Output is correct |
20 |
Correct |
231 ms |
6004 KB |
Output is correct |
21 |
Correct |
230 ms |
6000 KB |
Output is correct |
22 |
Correct |
204 ms |
5964 KB |
Output is correct |
23 |
Incorrect |
240 ms |
5880 KB |
Wrong Answer [2] |
24 |
Halted |
0 ms |
0 KB |
- |