#include <cstdio>
#include <vector>
#include<algorithm>
#include<cmath>
#include "minerals.h"
using namespace std;
int used[110000];
vector<int>gr[2];
void rec(vector<int>A,vector<int>B,int c){
if(A.size()==0)return;
if(A.size()==1){
used[A[0]]=B[0];
used[B[0]]=A[0];
return;
}
int rac=0;
int SZ= (3 - sqrt(5)) / 2*A.size();
if(c==0){
SZ= (1-(3 - sqrt(5)) / 2 )*A.size();
}
if(SZ==0)SZ++;
if(SZ==A.size())SZ--;
vector<int>X1;
vector<int>X2;
vector<int>Y1;
vector<int>Y2;
if(c==1){
for(int i=0;i<SZ;i++){
rac=Query(A[i]+1);
}
for(int i=0;i<A.size();i++){
if(i<SZ)X1.push_back(A[i]);
else X2.push_back(A[i]);
}
for(int i=0;i<B.size();i++){
if(Y1.size()==X1.size()){
Y2.push_back(B[i]);
}else if(X2.size()==Y2.size()){
Y1.push_back(B[i]);
}else{
int tmp=Query(B[i]+1);
if(rac!=tmp){
Y1.push_back(B[i]);
}else Y2.push_back(B[i]);
rac=tmp;
}
}
}else{
for(int i=SZ;i<A.size();i++){
rac=Query(A[i]+1);
}
for(int i=0;i<A.size();i++){
if(i<SZ)X1.push_back(A[i]);
else X2.push_back(A[i]);
}
for(int i=0;i<B.size();i++){
if(Y1.size()==X1.size()){
Y2.push_back(B[i]);
}else if(X2.size()==Y2.size()){
Y1.push_back(B[i]);
}else{
int tmp=Query(B[i]+1);
if(rac!=tmp){
Y1.push_back(B[i]);
}else Y2.push_back(B[i]);
rac=tmp;
}
}
}
rec(X1,Y1,0);
rec(X2,Y2,1);
}
void Solve(int N){
int cur=0;
for(int i=0;i<N*2;i++){
int tmp=Query(i+1);
if(cur<tmp){
gr[0].push_back(i);
}else gr[1].push_back(i);
cur=tmp;
}
random_shuffle(gr[0].begin(),gr[0].end());
random_shuffle(gr[1].begin(),gr[1].end());
rec(gr[0],gr[1],1);
for(int i=0;i<N;i++){
Answer(gr[0][i]+1,used[gr[0][i]]+1);
}
}
Compilation message
minerals.cpp: In function 'void rec(std::vector<int>, std::vector<int>, int)':
minerals.cpp:23:7: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(SZ==A.size())SZ--;
~~^~~~~~~~~~
minerals.cpp:32:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<A.size();i++){
~^~~~~~~~~
minerals.cpp:36:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<B.size();i++){
~^~~~~~~~~
minerals.cpp:50:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=SZ;i<A.size();i++){
~^~~~~~~~~
minerals.cpp:53:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<A.size();i++){
~^~~~~~~~~
minerals.cpp:57:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<B.size();i++){
~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
512 KB |
Output is correct |
3 |
Correct |
7 ms |
712 KB |
Output is correct |
4 |
Correct |
12 ms |
944 KB |
Output is correct |
5 |
Correct |
23 ms |
1532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
6 ms |
512 KB |
Output is correct |
7 |
Correct |
7 ms |
712 KB |
Output is correct |
8 |
Correct |
12 ms |
944 KB |
Output is correct |
9 |
Correct |
23 ms |
1532 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
15 ms |
1196 KB |
Output is correct |
12 |
Correct |
25 ms |
1516 KB |
Output is correct |
13 |
Correct |
21 ms |
1728 KB |
Output is correct |
14 |
Correct |
25 ms |
1568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
6 ms |
512 KB |
Output is correct |
7 |
Correct |
7 ms |
712 KB |
Output is correct |
8 |
Correct |
12 ms |
944 KB |
Output is correct |
9 |
Correct |
23 ms |
1532 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
15 ms |
1196 KB |
Output is correct |
12 |
Correct |
25 ms |
1516 KB |
Output is correct |
13 |
Correct |
21 ms |
1728 KB |
Output is correct |
14 |
Correct |
25 ms |
1568 KB |
Output is correct |
15 |
Correct |
80 ms |
3456 KB |
Output is correct |
16 |
Correct |
81 ms |
3568 KB |
Output is correct |
17 |
Correct |
87 ms |
3516 KB |
Output is correct |
18 |
Correct |
69 ms |
3388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
6 ms |
512 KB |
Output is correct |
7 |
Correct |
7 ms |
712 KB |
Output is correct |
8 |
Correct |
12 ms |
944 KB |
Output is correct |
9 |
Correct |
23 ms |
1532 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
15 ms |
1196 KB |
Output is correct |
12 |
Correct |
25 ms |
1516 KB |
Output is correct |
13 |
Correct |
21 ms |
1728 KB |
Output is correct |
14 |
Correct |
25 ms |
1568 KB |
Output is correct |
15 |
Correct |
80 ms |
3456 KB |
Output is correct |
16 |
Correct |
81 ms |
3568 KB |
Output is correct |
17 |
Correct |
87 ms |
3516 KB |
Output is correct |
18 |
Correct |
69 ms |
3388 KB |
Output is correct |
19 |
Correct |
62 ms |
3568 KB |
Output is correct |
20 |
Correct |
62 ms |
3656 KB |
Output is correct |
21 |
Correct |
59 ms |
3640 KB |
Output is correct |
22 |
Correct |
69 ms |
3436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
6 ms |
512 KB |
Output is correct |
7 |
Correct |
7 ms |
712 KB |
Output is correct |
8 |
Correct |
12 ms |
944 KB |
Output is correct |
9 |
Correct |
23 ms |
1532 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
15 ms |
1196 KB |
Output is correct |
12 |
Correct |
25 ms |
1516 KB |
Output is correct |
13 |
Correct |
21 ms |
1728 KB |
Output is correct |
14 |
Correct |
25 ms |
1568 KB |
Output is correct |
15 |
Correct |
80 ms |
3456 KB |
Output is correct |
16 |
Correct |
81 ms |
3568 KB |
Output is correct |
17 |
Correct |
87 ms |
3516 KB |
Output is correct |
18 |
Correct |
69 ms |
3388 KB |
Output is correct |
19 |
Correct |
62 ms |
3568 KB |
Output is correct |
20 |
Correct |
62 ms |
3656 KB |
Output is correct |
21 |
Correct |
59 ms |
3640 KB |
Output is correct |
22 |
Correct |
69 ms |
3436 KB |
Output is correct |
23 |
Correct |
69 ms |
3600 KB |
Output is correct |
24 |
Correct |
64 ms |
3596 KB |
Output is correct |
25 |
Correct |
65 ms |
3676 KB |
Output is correct |
26 |
Correct |
59 ms |
3600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
6 ms |
512 KB |
Output is correct |
7 |
Correct |
7 ms |
712 KB |
Output is correct |
8 |
Correct |
12 ms |
944 KB |
Output is correct |
9 |
Correct |
23 ms |
1532 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
15 ms |
1196 KB |
Output is correct |
12 |
Correct |
25 ms |
1516 KB |
Output is correct |
13 |
Correct |
21 ms |
1728 KB |
Output is correct |
14 |
Correct |
25 ms |
1568 KB |
Output is correct |
15 |
Correct |
80 ms |
3456 KB |
Output is correct |
16 |
Correct |
81 ms |
3568 KB |
Output is correct |
17 |
Correct |
87 ms |
3516 KB |
Output is correct |
18 |
Correct |
69 ms |
3388 KB |
Output is correct |
19 |
Correct |
62 ms |
3568 KB |
Output is correct |
20 |
Correct |
62 ms |
3656 KB |
Output is correct |
21 |
Correct |
59 ms |
3640 KB |
Output is correct |
22 |
Correct |
69 ms |
3436 KB |
Output is correct |
23 |
Correct |
69 ms |
3600 KB |
Output is correct |
24 |
Correct |
64 ms |
3596 KB |
Output is correct |
25 |
Correct |
65 ms |
3676 KB |
Output is correct |
26 |
Correct |
59 ms |
3600 KB |
Output is correct |
27 |
Correct |
66 ms |
3700 KB |
Output is correct |
28 |
Correct |
100 ms |
3864 KB |
Output is correct |
29 |
Correct |
88 ms |
3692 KB |
Output is correct |
30 |
Correct |
70 ms |
3596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
6 ms |
512 KB |
Output is correct |
7 |
Correct |
7 ms |
712 KB |
Output is correct |
8 |
Correct |
12 ms |
944 KB |
Output is correct |
9 |
Correct |
23 ms |
1532 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
15 ms |
1196 KB |
Output is correct |
12 |
Correct |
25 ms |
1516 KB |
Output is correct |
13 |
Correct |
21 ms |
1728 KB |
Output is correct |
14 |
Correct |
25 ms |
1568 KB |
Output is correct |
15 |
Correct |
80 ms |
3456 KB |
Output is correct |
16 |
Correct |
81 ms |
3568 KB |
Output is correct |
17 |
Correct |
87 ms |
3516 KB |
Output is correct |
18 |
Correct |
69 ms |
3388 KB |
Output is correct |
19 |
Correct |
62 ms |
3568 KB |
Output is correct |
20 |
Correct |
62 ms |
3656 KB |
Output is correct |
21 |
Correct |
59 ms |
3640 KB |
Output is correct |
22 |
Correct |
69 ms |
3436 KB |
Output is correct |
23 |
Correct |
69 ms |
3600 KB |
Output is correct |
24 |
Correct |
64 ms |
3596 KB |
Output is correct |
25 |
Correct |
65 ms |
3676 KB |
Output is correct |
26 |
Correct |
59 ms |
3600 KB |
Output is correct |
27 |
Correct |
66 ms |
3700 KB |
Output is correct |
28 |
Correct |
100 ms |
3864 KB |
Output is correct |
29 |
Correct |
88 ms |
3692 KB |
Output is correct |
30 |
Correct |
70 ms |
3596 KB |
Output is correct |
31 |
Correct |
93 ms |
3796 KB |
Output is correct |
32 |
Correct |
84 ms |
3752 KB |
Output is correct |
33 |
Correct |
77 ms |
3812 KB |
Output is correct |
34 |
Correct |
70 ms |
3624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
6 ms |
512 KB |
Output is correct |
7 |
Correct |
7 ms |
712 KB |
Output is correct |
8 |
Correct |
12 ms |
944 KB |
Output is correct |
9 |
Correct |
23 ms |
1532 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
15 ms |
1196 KB |
Output is correct |
12 |
Correct |
25 ms |
1516 KB |
Output is correct |
13 |
Correct |
21 ms |
1728 KB |
Output is correct |
14 |
Correct |
25 ms |
1568 KB |
Output is correct |
15 |
Correct |
80 ms |
3456 KB |
Output is correct |
16 |
Correct |
81 ms |
3568 KB |
Output is correct |
17 |
Correct |
87 ms |
3516 KB |
Output is correct |
18 |
Correct |
69 ms |
3388 KB |
Output is correct |
19 |
Correct |
62 ms |
3568 KB |
Output is correct |
20 |
Correct |
62 ms |
3656 KB |
Output is correct |
21 |
Correct |
59 ms |
3640 KB |
Output is correct |
22 |
Correct |
69 ms |
3436 KB |
Output is correct |
23 |
Correct |
69 ms |
3600 KB |
Output is correct |
24 |
Correct |
64 ms |
3596 KB |
Output is correct |
25 |
Correct |
65 ms |
3676 KB |
Output is correct |
26 |
Correct |
59 ms |
3600 KB |
Output is correct |
27 |
Correct |
66 ms |
3700 KB |
Output is correct |
28 |
Correct |
100 ms |
3864 KB |
Output is correct |
29 |
Correct |
88 ms |
3692 KB |
Output is correct |
30 |
Correct |
70 ms |
3596 KB |
Output is correct |
31 |
Correct |
93 ms |
3796 KB |
Output is correct |
32 |
Correct |
84 ms |
3752 KB |
Output is correct |
33 |
Correct |
77 ms |
3812 KB |
Output is correct |
34 |
Correct |
70 ms |
3624 KB |
Output is correct |
35 |
Correct |
80 ms |
3864 KB |
Output is correct |
36 |
Correct |
100 ms |
3844 KB |
Output is correct |
37 |
Correct |
81 ms |
3816 KB |
Output is correct |
38 |
Correct |
84 ms |
3684 KB |
Output is correct |