#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;
#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, INF=1e9+7, C=1000;
int czy[2*LIM], lst=-1;
pair<int,int>dp[LIM];
bool pytaj(int x) {
czy[x]^=1;
int a=Query(x+1);
swap(a, lst);
return a!=lst;
}
void dc(vector<int>&X, vector<int>&Y) {
if(X.size()==1) {
Answer(X[0]+1, Y[0]+1);
return;
}
vector<int>AX, AY, BX, BY;
rep(i, dp[X.size()].nd) {
pytaj(X[i]);
AX.pb(X[i]);
}
for(int i=dp[X.size()].nd; i<X.size(); ++i) BX.pb(X[i]);
for(auto i : Y) if(czy[X[0]]==pytaj(i)) BY.pb(i); else AY.pb(i);
dc(AX, AY);
dc(BX, BY);
}
void Solve(int n) {
for(int i=2; i<=n; ++i) {
dp[i]={INF, INF};
for(int k=max(i/2-C, 1); k<min(i, i/2+C); ++k) dp[i]=min(dp[i], {i+k+dp[k].st+dp[i-k].st, k});
}
vector<int>X, Y;
rep(i, 2*n) {
if(pytaj(i)) X.pb(i);
else Y.pb(i);
}
dc(X, Y);
}
Compilation message
minerals.cpp: In function 'void dc(std::vector<int>&, std::vector<int>&)':
minerals.cpp:28:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for(int i=dp[X.size()].nd; i<X.size(); ++i) BX.pb(X[i]);
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
320 KB |
Output is correct |
2 |
Correct |
6 ms |
464 KB |
Output is correct |
3 |
Correct |
17 ms |
608 KB |
Output is correct |
4 |
Correct |
41 ms |
892 KB |
Output is correct |
5 |
Correct |
81 ms |
1452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
320 KB |
Output is correct |
6 |
Correct |
6 ms |
464 KB |
Output is correct |
7 |
Correct |
17 ms |
608 KB |
Output is correct |
8 |
Correct |
41 ms |
892 KB |
Output is correct |
9 |
Correct |
81 ms |
1452 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
54 ms |
1052 KB |
Output is correct |
12 |
Correct |
82 ms |
1416 KB |
Output is correct |
13 |
Correct |
82 ms |
1492 KB |
Output is correct |
14 |
Correct |
80 ms |
1360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
320 KB |
Output is correct |
6 |
Correct |
6 ms |
464 KB |
Output is correct |
7 |
Correct |
17 ms |
608 KB |
Output is correct |
8 |
Correct |
41 ms |
892 KB |
Output is correct |
9 |
Correct |
81 ms |
1452 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
54 ms |
1052 KB |
Output is correct |
12 |
Correct |
82 ms |
1416 KB |
Output is correct |
13 |
Correct |
82 ms |
1492 KB |
Output is correct |
14 |
Correct |
80 ms |
1360 KB |
Output is correct |
15 |
Correct |
198 ms |
3268 KB |
Output is correct |
16 |
Correct |
197 ms |
3236 KB |
Output is correct |
17 |
Correct |
198 ms |
3172 KB |
Output is correct |
18 |
Correct |
193 ms |
3236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
320 KB |
Output is correct |
6 |
Correct |
6 ms |
464 KB |
Output is correct |
7 |
Correct |
17 ms |
608 KB |
Output is correct |
8 |
Correct |
41 ms |
892 KB |
Output is correct |
9 |
Correct |
81 ms |
1452 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
54 ms |
1052 KB |
Output is correct |
12 |
Correct |
82 ms |
1416 KB |
Output is correct |
13 |
Correct |
82 ms |
1492 KB |
Output is correct |
14 |
Correct |
80 ms |
1360 KB |
Output is correct |
15 |
Correct |
198 ms |
3268 KB |
Output is correct |
16 |
Correct |
197 ms |
3236 KB |
Output is correct |
17 |
Correct |
198 ms |
3172 KB |
Output is correct |
18 |
Correct |
193 ms |
3236 KB |
Output is correct |
19 |
Correct |
200 ms |
3244 KB |
Output is correct |
20 |
Correct |
206 ms |
3284 KB |
Output is correct |
21 |
Correct |
200 ms |
3280 KB |
Output is correct |
22 |
Correct |
195 ms |
3072 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
320 KB |
Output is correct |
6 |
Correct |
6 ms |
464 KB |
Output is correct |
7 |
Correct |
17 ms |
608 KB |
Output is correct |
8 |
Correct |
41 ms |
892 KB |
Output is correct |
9 |
Correct |
81 ms |
1452 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
54 ms |
1052 KB |
Output is correct |
12 |
Correct |
82 ms |
1416 KB |
Output is correct |
13 |
Correct |
82 ms |
1492 KB |
Output is correct |
14 |
Correct |
80 ms |
1360 KB |
Output is correct |
15 |
Correct |
198 ms |
3268 KB |
Output is correct |
16 |
Correct |
197 ms |
3236 KB |
Output is correct |
17 |
Correct |
198 ms |
3172 KB |
Output is correct |
18 |
Correct |
193 ms |
3236 KB |
Output is correct |
19 |
Correct |
200 ms |
3244 KB |
Output is correct |
20 |
Correct |
206 ms |
3284 KB |
Output is correct |
21 |
Correct |
200 ms |
3280 KB |
Output is correct |
22 |
Correct |
195 ms |
3072 KB |
Output is correct |
23 |
Correct |
207 ms |
3336 KB |
Output is correct |
24 |
Correct |
207 ms |
3404 KB |
Output is correct |
25 |
Correct |
201 ms |
3360 KB |
Output is correct |
26 |
Correct |
204 ms |
3180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
320 KB |
Output is correct |
6 |
Correct |
6 ms |
464 KB |
Output is correct |
7 |
Correct |
17 ms |
608 KB |
Output is correct |
8 |
Correct |
41 ms |
892 KB |
Output is correct |
9 |
Correct |
81 ms |
1452 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
54 ms |
1052 KB |
Output is correct |
12 |
Correct |
82 ms |
1416 KB |
Output is correct |
13 |
Correct |
82 ms |
1492 KB |
Output is correct |
14 |
Correct |
80 ms |
1360 KB |
Output is correct |
15 |
Correct |
198 ms |
3268 KB |
Output is correct |
16 |
Correct |
197 ms |
3236 KB |
Output is correct |
17 |
Correct |
198 ms |
3172 KB |
Output is correct |
18 |
Correct |
193 ms |
3236 KB |
Output is correct |
19 |
Correct |
200 ms |
3244 KB |
Output is correct |
20 |
Correct |
206 ms |
3284 KB |
Output is correct |
21 |
Correct |
200 ms |
3280 KB |
Output is correct |
22 |
Correct |
195 ms |
3072 KB |
Output is correct |
23 |
Correct |
207 ms |
3336 KB |
Output is correct |
24 |
Correct |
207 ms |
3404 KB |
Output is correct |
25 |
Correct |
201 ms |
3360 KB |
Output is correct |
26 |
Correct |
204 ms |
3180 KB |
Output is correct |
27 |
Correct |
211 ms |
3448 KB |
Output is correct |
28 |
Correct |
211 ms |
3368 KB |
Output is correct |
29 |
Correct |
208 ms |
3436 KB |
Output is correct |
30 |
Correct |
212 ms |
3224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
320 KB |
Output is correct |
6 |
Correct |
6 ms |
464 KB |
Output is correct |
7 |
Correct |
17 ms |
608 KB |
Output is correct |
8 |
Correct |
41 ms |
892 KB |
Output is correct |
9 |
Correct |
81 ms |
1452 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
54 ms |
1052 KB |
Output is correct |
12 |
Correct |
82 ms |
1416 KB |
Output is correct |
13 |
Correct |
82 ms |
1492 KB |
Output is correct |
14 |
Correct |
80 ms |
1360 KB |
Output is correct |
15 |
Correct |
198 ms |
3268 KB |
Output is correct |
16 |
Correct |
197 ms |
3236 KB |
Output is correct |
17 |
Correct |
198 ms |
3172 KB |
Output is correct |
18 |
Correct |
193 ms |
3236 KB |
Output is correct |
19 |
Correct |
200 ms |
3244 KB |
Output is correct |
20 |
Correct |
206 ms |
3284 KB |
Output is correct |
21 |
Correct |
200 ms |
3280 KB |
Output is correct |
22 |
Correct |
195 ms |
3072 KB |
Output is correct |
23 |
Correct |
207 ms |
3336 KB |
Output is correct |
24 |
Correct |
207 ms |
3404 KB |
Output is correct |
25 |
Correct |
201 ms |
3360 KB |
Output is correct |
26 |
Correct |
204 ms |
3180 KB |
Output is correct |
27 |
Correct |
211 ms |
3448 KB |
Output is correct |
28 |
Correct |
211 ms |
3368 KB |
Output is correct |
29 |
Correct |
208 ms |
3436 KB |
Output is correct |
30 |
Correct |
212 ms |
3224 KB |
Output is correct |
31 |
Incorrect |
215 ms |
3492 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
2 ms |
320 KB |
Output is correct |
6 |
Correct |
6 ms |
464 KB |
Output is correct |
7 |
Correct |
17 ms |
608 KB |
Output is correct |
8 |
Correct |
41 ms |
892 KB |
Output is correct |
9 |
Correct |
81 ms |
1452 KB |
Output is correct |
10 |
Correct |
2 ms |
336 KB |
Output is correct |
11 |
Correct |
54 ms |
1052 KB |
Output is correct |
12 |
Correct |
82 ms |
1416 KB |
Output is correct |
13 |
Correct |
82 ms |
1492 KB |
Output is correct |
14 |
Correct |
80 ms |
1360 KB |
Output is correct |
15 |
Correct |
198 ms |
3268 KB |
Output is correct |
16 |
Correct |
197 ms |
3236 KB |
Output is correct |
17 |
Correct |
198 ms |
3172 KB |
Output is correct |
18 |
Correct |
193 ms |
3236 KB |
Output is correct |
19 |
Correct |
200 ms |
3244 KB |
Output is correct |
20 |
Correct |
206 ms |
3284 KB |
Output is correct |
21 |
Correct |
200 ms |
3280 KB |
Output is correct |
22 |
Correct |
195 ms |
3072 KB |
Output is correct |
23 |
Correct |
207 ms |
3336 KB |
Output is correct |
24 |
Correct |
207 ms |
3404 KB |
Output is correct |
25 |
Correct |
201 ms |
3360 KB |
Output is correct |
26 |
Correct |
204 ms |
3180 KB |
Output is correct |
27 |
Correct |
211 ms |
3448 KB |
Output is correct |
28 |
Correct |
211 ms |
3368 KB |
Output is correct |
29 |
Correct |
208 ms |
3436 KB |
Output is correct |
30 |
Correct |
212 ms |
3224 KB |
Output is correct |
31 |
Incorrect |
215 ms |
3492 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |