#include "minerals.h"
#include <bits/stdc++.h>
#define forf(i,a,b) for(int i = a; i<=b; i++)
using namespace std;
int N,M;
set<int> S;
vector<int> pre,sec;
vector<int> match;
int last;
vector<int> ran;
void dnc(int s, int e , vector<int> v , int d){
if(s==e){
for(int i : v) match[i] = sec[s];
return;
}
int m = s+e>>1;
int now = 0;
if(last > m) forf(i,m+1,last){ now = Query(sec[i]); }
else forf(i,last+1,m){ now = Query(sec[i]); }
vector<int> v1,v2;
for(int i : v){
int prv = now;
if(v1.size() == (m-s+1)){ v2.push_back(i); continue; }
if(v2.size() == (m-s+1)){ v1.push_back(i); continue; }
now = Query(pre[i]);
if(now == prv) v1.push_back(i);
else v2.push_back(i);
}
last = m;
dnc(m+1,e,v2,d+1);
last = m;
dnc(s,m,v1,d+1);
}
void Solve(int N) {
int now = 0;
forf(i,1,2*N){
int prv = now;
if(pre.size() == N){ sec.push_back(i); Query(i); continue; }
if(sec.size() == N){ pre.push_back(i); continue; }
now = Query(i);
if(now == prv+1){
pre.push_back(i);
}
else{
sec.push_back(i);
}
}
last = N-1;
assert(pre.size() == N);
match.resize(N);
vector<int> v; forf(i,0,N-1) v.push_back(i);
dnc(0,N-1,v,1);
forf(i,0,N-1) Answer(pre[i],match[i]);
}
Compilation message
minerals.cpp: In function 'void dnc(int, int, std::vector<int>, int)':
minerals.cpp:18:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
18 | int m = s+e>>1;
| ~^~
minerals.cpp:26:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
26 | if(v1.size() == (m-s+1)){ v2.push_back(i); continue; }
| ~~~~~~~~~~^~~~~~~~~~
minerals.cpp:27:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
27 | if(v2.size() == (m-s+1)){ v1.push_back(i); continue; }
| ~~~~~~~~~~^~~~~~~~~~
minerals.cpp: In function 'void Solve(int)':
minerals.cpp:42:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
42 | if(pre.size() == N){ sec.push_back(i); Query(i); continue; }
| ~~~~~~~~~~~^~~~
minerals.cpp:43:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
43 | if(sec.size() == N){ pre.push_back(i); continue; }
| ~~~~~~~~~~~^~~~
In file included from /usr/include/c++/10/cassert:44,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
from minerals.cpp:2:
minerals.cpp:53:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
53 | assert(pre.size() == N);
| ~~~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
500 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
2 ms |
468 KB |
Output is correct |
4 |
Correct |
5 ms |
764 KB |
Output is correct |
5 |
Correct |
8 ms |
1320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
500 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
5 ms |
764 KB |
Output is correct |
9 |
Correct |
8 ms |
1320 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
6 ms |
1112 KB |
Output is correct |
12 |
Correct |
8 ms |
1320 KB |
Output is correct |
13 |
Correct |
7 ms |
1540 KB |
Output is correct |
14 |
Correct |
7 ms |
1368 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
500 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
5 ms |
764 KB |
Output is correct |
9 |
Correct |
8 ms |
1320 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
6 ms |
1112 KB |
Output is correct |
12 |
Correct |
8 ms |
1320 KB |
Output is correct |
13 |
Correct |
7 ms |
1540 KB |
Output is correct |
14 |
Correct |
7 ms |
1368 KB |
Output is correct |
15 |
Correct |
28 ms |
2876 KB |
Output is correct |
16 |
Correct |
24 ms |
2572 KB |
Output is correct |
17 |
Correct |
15 ms |
2780 KB |
Output is correct |
18 |
Correct |
16 ms |
2620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
500 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
5 ms |
764 KB |
Output is correct |
9 |
Correct |
8 ms |
1320 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
6 ms |
1112 KB |
Output is correct |
12 |
Correct |
8 ms |
1320 KB |
Output is correct |
13 |
Correct |
7 ms |
1540 KB |
Output is correct |
14 |
Correct |
7 ms |
1368 KB |
Output is correct |
15 |
Correct |
28 ms |
2876 KB |
Output is correct |
16 |
Correct |
24 ms |
2572 KB |
Output is correct |
17 |
Correct |
15 ms |
2780 KB |
Output is correct |
18 |
Correct |
16 ms |
2620 KB |
Output is correct |
19 |
Correct |
24 ms |
2880 KB |
Output is correct |
20 |
Correct |
26 ms |
2616 KB |
Output is correct |
21 |
Correct |
18 ms |
2748 KB |
Output is correct |
22 |
Correct |
16 ms |
2604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
500 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
5 ms |
764 KB |
Output is correct |
9 |
Correct |
8 ms |
1320 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
6 ms |
1112 KB |
Output is correct |
12 |
Correct |
8 ms |
1320 KB |
Output is correct |
13 |
Correct |
7 ms |
1540 KB |
Output is correct |
14 |
Correct |
7 ms |
1368 KB |
Output is correct |
15 |
Correct |
28 ms |
2876 KB |
Output is correct |
16 |
Correct |
24 ms |
2572 KB |
Output is correct |
17 |
Correct |
15 ms |
2780 KB |
Output is correct |
18 |
Correct |
16 ms |
2620 KB |
Output is correct |
19 |
Correct |
24 ms |
2880 KB |
Output is correct |
20 |
Correct |
26 ms |
2616 KB |
Output is correct |
21 |
Correct |
18 ms |
2748 KB |
Output is correct |
22 |
Correct |
16 ms |
2604 KB |
Output is correct |
23 |
Correct |
26 ms |
2772 KB |
Output is correct |
24 |
Correct |
28 ms |
2764 KB |
Output is correct |
25 |
Correct |
16 ms |
2900 KB |
Output is correct |
26 |
Correct |
16 ms |
2516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
500 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
5 ms |
764 KB |
Output is correct |
9 |
Correct |
8 ms |
1320 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
6 ms |
1112 KB |
Output is correct |
12 |
Correct |
8 ms |
1320 KB |
Output is correct |
13 |
Correct |
7 ms |
1540 KB |
Output is correct |
14 |
Correct |
7 ms |
1368 KB |
Output is correct |
15 |
Correct |
28 ms |
2876 KB |
Output is correct |
16 |
Correct |
24 ms |
2572 KB |
Output is correct |
17 |
Correct |
15 ms |
2780 KB |
Output is correct |
18 |
Correct |
16 ms |
2620 KB |
Output is correct |
19 |
Correct |
24 ms |
2880 KB |
Output is correct |
20 |
Correct |
26 ms |
2616 KB |
Output is correct |
21 |
Correct |
18 ms |
2748 KB |
Output is correct |
22 |
Correct |
16 ms |
2604 KB |
Output is correct |
23 |
Correct |
26 ms |
2772 KB |
Output is correct |
24 |
Correct |
28 ms |
2764 KB |
Output is correct |
25 |
Correct |
16 ms |
2900 KB |
Output is correct |
26 |
Correct |
16 ms |
2516 KB |
Output is correct |
27 |
Correct |
27 ms |
2736 KB |
Output is correct |
28 |
Correct |
27 ms |
2812 KB |
Output is correct |
29 |
Correct |
19 ms |
2788 KB |
Output is correct |
30 |
Correct |
17 ms |
2616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
500 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
5 ms |
764 KB |
Output is correct |
9 |
Correct |
8 ms |
1320 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
6 ms |
1112 KB |
Output is correct |
12 |
Correct |
8 ms |
1320 KB |
Output is correct |
13 |
Correct |
7 ms |
1540 KB |
Output is correct |
14 |
Correct |
7 ms |
1368 KB |
Output is correct |
15 |
Correct |
28 ms |
2876 KB |
Output is correct |
16 |
Correct |
24 ms |
2572 KB |
Output is correct |
17 |
Correct |
15 ms |
2780 KB |
Output is correct |
18 |
Correct |
16 ms |
2620 KB |
Output is correct |
19 |
Correct |
24 ms |
2880 KB |
Output is correct |
20 |
Correct |
26 ms |
2616 KB |
Output is correct |
21 |
Correct |
18 ms |
2748 KB |
Output is correct |
22 |
Correct |
16 ms |
2604 KB |
Output is correct |
23 |
Correct |
26 ms |
2772 KB |
Output is correct |
24 |
Correct |
28 ms |
2764 KB |
Output is correct |
25 |
Correct |
16 ms |
2900 KB |
Output is correct |
26 |
Correct |
16 ms |
2516 KB |
Output is correct |
27 |
Correct |
27 ms |
2736 KB |
Output is correct |
28 |
Correct |
27 ms |
2812 KB |
Output is correct |
29 |
Correct |
19 ms |
2788 KB |
Output is correct |
30 |
Correct |
17 ms |
2616 KB |
Output is correct |
31 |
Incorrect |
25 ms |
3024 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
500 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
5 ms |
764 KB |
Output is correct |
9 |
Correct |
8 ms |
1320 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
6 ms |
1112 KB |
Output is correct |
12 |
Correct |
8 ms |
1320 KB |
Output is correct |
13 |
Correct |
7 ms |
1540 KB |
Output is correct |
14 |
Correct |
7 ms |
1368 KB |
Output is correct |
15 |
Correct |
28 ms |
2876 KB |
Output is correct |
16 |
Correct |
24 ms |
2572 KB |
Output is correct |
17 |
Correct |
15 ms |
2780 KB |
Output is correct |
18 |
Correct |
16 ms |
2620 KB |
Output is correct |
19 |
Correct |
24 ms |
2880 KB |
Output is correct |
20 |
Correct |
26 ms |
2616 KB |
Output is correct |
21 |
Correct |
18 ms |
2748 KB |
Output is correct |
22 |
Correct |
16 ms |
2604 KB |
Output is correct |
23 |
Correct |
26 ms |
2772 KB |
Output is correct |
24 |
Correct |
28 ms |
2764 KB |
Output is correct |
25 |
Correct |
16 ms |
2900 KB |
Output is correct |
26 |
Correct |
16 ms |
2516 KB |
Output is correct |
27 |
Correct |
27 ms |
2736 KB |
Output is correct |
28 |
Correct |
27 ms |
2812 KB |
Output is correct |
29 |
Correct |
19 ms |
2788 KB |
Output is correct |
30 |
Correct |
17 ms |
2616 KB |
Output is correct |
31 |
Incorrect |
25 ms |
3024 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |