#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const int LIM=5e4+7;
vector<int>T, zapalone;
int czy[LIM], lst=-1;
bool pytaj(int x) {
int a=Query(x+1);
swap(a, lst);
return a!=lst;
}
void dc(int l, int r, vector<int>&V) {
if(l==r) {
Answer(T[l]+1, V[0]+1);
return;
}
int mid=(l+r)/2;
vector<int>tmp;
for(auto i : zapalone) {
if(i<l || i>mid) {
pytaj(T[i]);
czy[i]=0;
} else tmp.pb(i);
}
zapalone=tmp;
for(int i=l; i<=mid; ++i) if(!czy[i]) {
pytaj(T[i]);
zapalone.pb(i);
czy[i]=1;
}
vector<int>A, B;
for(auto i : V) {
if(pytaj(i)) B.pb(i); else A.pb(i);
}
dc(l, mid, A);
dc(mid+1, r, B);
}
void Solve(int n) {
vector<int>V;
rep(i, 2*n) {
if(pytaj(i)) T.pb(i);
else V.pb(i);
}
rep(i, T.size()) {
zapalone.pb(i);
czy[i]=1;
}
dc(0, n-1, V);
}
Compilation message
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:5:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
5 | #define rep(a, b) for(int a = 0; a < (b); ++a)
| ^
minerals.cpp:50:2: note: in expansion of macro 'rep'
50 | rep(i, T.size()) {
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
372 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
4 |
Correct |
5 ms |
720 KB |
Output is correct |
5 |
Correct |
11 ms |
1056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
372 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
464 KB |
Output is correct |
8 |
Correct |
5 ms |
720 KB |
Output is correct |
9 |
Correct |
11 ms |
1056 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
7 ms |
848 KB |
Output is correct |
12 |
Correct |
9 ms |
1104 KB |
Output is correct |
13 |
Correct |
6 ms |
1104 KB |
Output is correct |
14 |
Correct |
8 ms |
1096 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
372 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
464 KB |
Output is correct |
8 |
Correct |
5 ms |
720 KB |
Output is correct |
9 |
Correct |
11 ms |
1056 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
7 ms |
848 KB |
Output is correct |
12 |
Correct |
9 ms |
1104 KB |
Output is correct |
13 |
Correct |
6 ms |
1104 KB |
Output is correct |
14 |
Correct |
8 ms |
1096 KB |
Output is correct |
15 |
Correct |
25 ms |
2684 KB |
Output is correct |
16 |
Correct |
24 ms |
2636 KB |
Output is correct |
17 |
Correct |
20 ms |
2636 KB |
Output is correct |
18 |
Correct |
21 ms |
2536 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
372 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
464 KB |
Output is correct |
8 |
Correct |
5 ms |
720 KB |
Output is correct |
9 |
Correct |
11 ms |
1056 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
7 ms |
848 KB |
Output is correct |
12 |
Correct |
9 ms |
1104 KB |
Output is correct |
13 |
Correct |
6 ms |
1104 KB |
Output is correct |
14 |
Correct |
8 ms |
1096 KB |
Output is correct |
15 |
Correct |
25 ms |
2684 KB |
Output is correct |
16 |
Correct |
24 ms |
2636 KB |
Output is correct |
17 |
Correct |
20 ms |
2636 KB |
Output is correct |
18 |
Correct |
21 ms |
2536 KB |
Output is correct |
19 |
Correct |
21 ms |
2756 KB |
Output is correct |
20 |
Correct |
21 ms |
2764 KB |
Output is correct |
21 |
Correct |
20 ms |
2708 KB |
Output is correct |
22 |
Correct |
26 ms |
2500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
372 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
464 KB |
Output is correct |
8 |
Correct |
5 ms |
720 KB |
Output is correct |
9 |
Correct |
11 ms |
1056 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
7 ms |
848 KB |
Output is correct |
12 |
Correct |
9 ms |
1104 KB |
Output is correct |
13 |
Correct |
6 ms |
1104 KB |
Output is correct |
14 |
Correct |
8 ms |
1096 KB |
Output is correct |
15 |
Correct |
25 ms |
2684 KB |
Output is correct |
16 |
Correct |
24 ms |
2636 KB |
Output is correct |
17 |
Correct |
20 ms |
2636 KB |
Output is correct |
18 |
Correct |
21 ms |
2536 KB |
Output is correct |
19 |
Correct |
21 ms |
2756 KB |
Output is correct |
20 |
Correct |
21 ms |
2764 KB |
Output is correct |
21 |
Correct |
20 ms |
2708 KB |
Output is correct |
22 |
Correct |
26 ms |
2500 KB |
Output is correct |
23 |
Incorrect |
22 ms |
2816 KB |
Wrong Answer [2] |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
372 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
464 KB |
Output is correct |
8 |
Correct |
5 ms |
720 KB |
Output is correct |
9 |
Correct |
11 ms |
1056 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
7 ms |
848 KB |
Output is correct |
12 |
Correct |
9 ms |
1104 KB |
Output is correct |
13 |
Correct |
6 ms |
1104 KB |
Output is correct |
14 |
Correct |
8 ms |
1096 KB |
Output is correct |
15 |
Correct |
25 ms |
2684 KB |
Output is correct |
16 |
Correct |
24 ms |
2636 KB |
Output is correct |
17 |
Correct |
20 ms |
2636 KB |
Output is correct |
18 |
Correct |
21 ms |
2536 KB |
Output is correct |
19 |
Correct |
21 ms |
2756 KB |
Output is correct |
20 |
Correct |
21 ms |
2764 KB |
Output is correct |
21 |
Correct |
20 ms |
2708 KB |
Output is correct |
22 |
Correct |
26 ms |
2500 KB |
Output is correct |
23 |
Incorrect |
22 ms |
2816 KB |
Wrong Answer [2] |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
372 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
464 KB |
Output is correct |
8 |
Correct |
5 ms |
720 KB |
Output is correct |
9 |
Correct |
11 ms |
1056 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
7 ms |
848 KB |
Output is correct |
12 |
Correct |
9 ms |
1104 KB |
Output is correct |
13 |
Correct |
6 ms |
1104 KB |
Output is correct |
14 |
Correct |
8 ms |
1096 KB |
Output is correct |
15 |
Correct |
25 ms |
2684 KB |
Output is correct |
16 |
Correct |
24 ms |
2636 KB |
Output is correct |
17 |
Correct |
20 ms |
2636 KB |
Output is correct |
18 |
Correct |
21 ms |
2536 KB |
Output is correct |
19 |
Correct |
21 ms |
2756 KB |
Output is correct |
20 |
Correct |
21 ms |
2764 KB |
Output is correct |
21 |
Correct |
20 ms |
2708 KB |
Output is correct |
22 |
Correct |
26 ms |
2500 KB |
Output is correct |
23 |
Incorrect |
22 ms |
2816 KB |
Wrong Answer [2] |
24 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
372 KB |
Output is correct |
6 |
Correct |
1 ms |
336 KB |
Output is correct |
7 |
Correct |
2 ms |
464 KB |
Output is correct |
8 |
Correct |
5 ms |
720 KB |
Output is correct |
9 |
Correct |
11 ms |
1056 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
7 ms |
848 KB |
Output is correct |
12 |
Correct |
9 ms |
1104 KB |
Output is correct |
13 |
Correct |
6 ms |
1104 KB |
Output is correct |
14 |
Correct |
8 ms |
1096 KB |
Output is correct |
15 |
Correct |
25 ms |
2684 KB |
Output is correct |
16 |
Correct |
24 ms |
2636 KB |
Output is correct |
17 |
Correct |
20 ms |
2636 KB |
Output is correct |
18 |
Correct |
21 ms |
2536 KB |
Output is correct |
19 |
Correct |
21 ms |
2756 KB |
Output is correct |
20 |
Correct |
21 ms |
2764 KB |
Output is correct |
21 |
Correct |
20 ms |
2708 KB |
Output is correct |
22 |
Correct |
26 ms |
2500 KB |
Output is correct |
23 |
Incorrect |
22 ms |
2816 KB |
Wrong Answer [2] |
24 |
Halted |
0 ms |
0 KB |
- |