#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=5000;
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;
}
if(X.size()==2) {
pytaj(X[0]);
if(czy[X[0]]) swap(X[0], X[1]);
if(!pytaj(Y[0])) swap(Y[0], Y[1]);
Answer(X[0]+1, Y[0]+1);
Answer(X[1]+1, Y[1]+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) {
dp[2]={2, 0};
for(int i=3; 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:36:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for(int i=dp[X.size()].nd; i<X.size(); ++i) BX.pb(X[i]);
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
4 ms |
600 KB |
Output is correct |
3 |
Correct |
11 ms |
600 KB |
Output is correct |
4 |
Correct |
40 ms |
856 KB |
Output is correct |
5 |
Correct |
118 ms |
1564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
600 KB |
Output is correct |
7 |
Correct |
11 ms |
600 KB |
Output is correct |
8 |
Correct |
40 ms |
856 KB |
Output is correct |
9 |
Correct |
118 ms |
1564 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
69 ms |
1068 KB |
Output is correct |
12 |
Correct |
117 ms |
1644 KB |
Output is correct |
13 |
Correct |
116 ms |
1632 KB |
Output is correct |
14 |
Correct |
118 ms |
1612 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
600 KB |
Output is correct |
7 |
Correct |
11 ms |
600 KB |
Output is correct |
8 |
Correct |
40 ms |
856 KB |
Output is correct |
9 |
Correct |
118 ms |
1564 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
69 ms |
1068 KB |
Output is correct |
12 |
Correct |
117 ms |
1644 KB |
Output is correct |
13 |
Correct |
116 ms |
1632 KB |
Output is correct |
14 |
Correct |
118 ms |
1612 KB |
Output is correct |
15 |
Correct |
366 ms |
3536 KB |
Output is correct |
16 |
Correct |
395 ms |
3504 KB |
Output is correct |
17 |
Correct |
353 ms |
3344 KB |
Output is correct |
18 |
Correct |
361 ms |
3328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
600 KB |
Output is correct |
7 |
Correct |
11 ms |
600 KB |
Output is correct |
8 |
Correct |
40 ms |
856 KB |
Output is correct |
9 |
Correct |
118 ms |
1564 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
69 ms |
1068 KB |
Output is correct |
12 |
Correct |
117 ms |
1644 KB |
Output is correct |
13 |
Correct |
116 ms |
1632 KB |
Output is correct |
14 |
Correct |
118 ms |
1612 KB |
Output is correct |
15 |
Correct |
366 ms |
3536 KB |
Output is correct |
16 |
Correct |
395 ms |
3504 KB |
Output is correct |
17 |
Correct |
353 ms |
3344 KB |
Output is correct |
18 |
Correct |
361 ms |
3328 KB |
Output is correct |
19 |
Correct |
390 ms |
3408 KB |
Output is correct |
20 |
Correct |
389 ms |
3472 KB |
Output is correct |
21 |
Correct |
365 ms |
3536 KB |
Output is correct |
22 |
Correct |
416 ms |
3416 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
600 KB |
Output is correct |
7 |
Correct |
11 ms |
600 KB |
Output is correct |
8 |
Correct |
40 ms |
856 KB |
Output is correct |
9 |
Correct |
118 ms |
1564 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
69 ms |
1068 KB |
Output is correct |
12 |
Correct |
117 ms |
1644 KB |
Output is correct |
13 |
Correct |
116 ms |
1632 KB |
Output is correct |
14 |
Correct |
118 ms |
1612 KB |
Output is correct |
15 |
Correct |
366 ms |
3536 KB |
Output is correct |
16 |
Correct |
395 ms |
3504 KB |
Output is correct |
17 |
Correct |
353 ms |
3344 KB |
Output is correct |
18 |
Correct |
361 ms |
3328 KB |
Output is correct |
19 |
Correct |
390 ms |
3408 KB |
Output is correct |
20 |
Correct |
389 ms |
3472 KB |
Output is correct |
21 |
Correct |
365 ms |
3536 KB |
Output is correct |
22 |
Correct |
416 ms |
3416 KB |
Output is correct |
23 |
Correct |
387 ms |
3564 KB |
Output is correct |
24 |
Correct |
414 ms |
3576 KB |
Output is correct |
25 |
Correct |
380 ms |
3740 KB |
Output is correct |
26 |
Correct |
459 ms |
3736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
600 KB |
Output is correct |
7 |
Correct |
11 ms |
600 KB |
Output is correct |
8 |
Correct |
40 ms |
856 KB |
Output is correct |
9 |
Correct |
118 ms |
1564 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
69 ms |
1068 KB |
Output is correct |
12 |
Correct |
117 ms |
1644 KB |
Output is correct |
13 |
Correct |
116 ms |
1632 KB |
Output is correct |
14 |
Correct |
118 ms |
1612 KB |
Output is correct |
15 |
Correct |
366 ms |
3536 KB |
Output is correct |
16 |
Correct |
395 ms |
3504 KB |
Output is correct |
17 |
Correct |
353 ms |
3344 KB |
Output is correct |
18 |
Correct |
361 ms |
3328 KB |
Output is correct |
19 |
Correct |
390 ms |
3408 KB |
Output is correct |
20 |
Correct |
389 ms |
3472 KB |
Output is correct |
21 |
Correct |
365 ms |
3536 KB |
Output is correct |
22 |
Correct |
416 ms |
3416 KB |
Output is correct |
23 |
Correct |
387 ms |
3564 KB |
Output is correct |
24 |
Correct |
414 ms |
3576 KB |
Output is correct |
25 |
Correct |
380 ms |
3740 KB |
Output is correct |
26 |
Correct |
459 ms |
3736 KB |
Output is correct |
27 |
Correct |
419 ms |
3856 KB |
Output is correct |
28 |
Correct |
414 ms |
3860 KB |
Output is correct |
29 |
Correct |
393 ms |
3648 KB |
Output is correct |
30 |
Correct |
415 ms |
3636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
600 KB |
Output is correct |
7 |
Correct |
11 ms |
600 KB |
Output is correct |
8 |
Correct |
40 ms |
856 KB |
Output is correct |
9 |
Correct |
118 ms |
1564 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
69 ms |
1068 KB |
Output is correct |
12 |
Correct |
117 ms |
1644 KB |
Output is correct |
13 |
Correct |
116 ms |
1632 KB |
Output is correct |
14 |
Correct |
118 ms |
1612 KB |
Output is correct |
15 |
Correct |
366 ms |
3536 KB |
Output is correct |
16 |
Correct |
395 ms |
3504 KB |
Output is correct |
17 |
Correct |
353 ms |
3344 KB |
Output is correct |
18 |
Correct |
361 ms |
3328 KB |
Output is correct |
19 |
Correct |
390 ms |
3408 KB |
Output is correct |
20 |
Correct |
389 ms |
3472 KB |
Output is correct |
21 |
Correct |
365 ms |
3536 KB |
Output is correct |
22 |
Correct |
416 ms |
3416 KB |
Output is correct |
23 |
Correct |
387 ms |
3564 KB |
Output is correct |
24 |
Correct |
414 ms |
3576 KB |
Output is correct |
25 |
Correct |
380 ms |
3740 KB |
Output is correct |
26 |
Correct |
459 ms |
3736 KB |
Output is correct |
27 |
Correct |
419 ms |
3856 KB |
Output is correct |
28 |
Correct |
414 ms |
3860 KB |
Output is correct |
29 |
Correct |
393 ms |
3648 KB |
Output is correct |
30 |
Correct |
415 ms |
3636 KB |
Output is correct |
31 |
Correct |
402 ms |
3796 KB |
Output is correct |
32 |
Correct |
415 ms |
3864 KB |
Output is correct |
33 |
Correct |
395 ms |
3688 KB |
Output is correct |
34 |
Correct |
412 ms |
3664 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
600 KB |
Output is correct |
7 |
Correct |
11 ms |
600 KB |
Output is correct |
8 |
Correct |
40 ms |
856 KB |
Output is correct |
9 |
Correct |
118 ms |
1564 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
69 ms |
1068 KB |
Output is correct |
12 |
Correct |
117 ms |
1644 KB |
Output is correct |
13 |
Correct |
116 ms |
1632 KB |
Output is correct |
14 |
Correct |
118 ms |
1612 KB |
Output is correct |
15 |
Correct |
366 ms |
3536 KB |
Output is correct |
16 |
Correct |
395 ms |
3504 KB |
Output is correct |
17 |
Correct |
353 ms |
3344 KB |
Output is correct |
18 |
Correct |
361 ms |
3328 KB |
Output is correct |
19 |
Correct |
390 ms |
3408 KB |
Output is correct |
20 |
Correct |
389 ms |
3472 KB |
Output is correct |
21 |
Correct |
365 ms |
3536 KB |
Output is correct |
22 |
Correct |
416 ms |
3416 KB |
Output is correct |
23 |
Correct |
387 ms |
3564 KB |
Output is correct |
24 |
Correct |
414 ms |
3576 KB |
Output is correct |
25 |
Correct |
380 ms |
3740 KB |
Output is correct |
26 |
Correct |
459 ms |
3736 KB |
Output is correct |
27 |
Correct |
419 ms |
3856 KB |
Output is correct |
28 |
Correct |
414 ms |
3860 KB |
Output is correct |
29 |
Correct |
393 ms |
3648 KB |
Output is correct |
30 |
Correct |
415 ms |
3636 KB |
Output is correct |
31 |
Correct |
402 ms |
3796 KB |
Output is correct |
32 |
Correct |
415 ms |
3864 KB |
Output is correct |
33 |
Correct |
395 ms |
3688 KB |
Output is correct |
34 |
Correct |
412 ms |
3664 KB |
Output is correct |
35 |
Incorrect |
388 ms |
3920 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |