#include "minerals.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
typedef pair<int,int> pii;
int ls,tp,isin[86005];
vector<int>a,b;
void find_ans(vector<int>A,vector<int>B)
{
int si=A.size(),ch,re;
vector<int>na1,nb1,na2,nb2;
if(A.size()==1)
{
Answer(A[0],B[0]);
return;
}
for(int i=0;i<si/2;i++)
{
if(isin[B[i]]==0)
{
ch=Query(B[i]);
isin[B[i]]=(isin[B[i]]+1)%2;
}
nb1.pb(B[i]);
}
for(int i=(si/2);i<si;i++)
{
if(isin[B[i]]==1)
{
ch=Query(B[i]);
isin[B[i]]=(isin[B[i]]+1)%2;
}
nb2.pb(B[i]);
}
for(int i=0;i<si;i++)
{
if(na1.size()==nb1.size())
{
na2.pb(A[i]);
}
else if(na2.size()==nb2.size())
{
na1.pb(A[i]);
}
else
{
re=Query(A[i]);
//printf("[%d %d]\n",re,ch);
isin[A[i]]=(isin[A[i]]+1)%2;
if(ch!=re)
{
na2.pb(A[i]);
}
else
{
na1.pb(A[i]);
}
ch=re;
}
}
find_ans(na1,nb1);
find_ans(na2,nb2);
return;
}
void Solve(int N)
{
for(int i=1;i<=2*N;i++)
{
tp=Query(i);
isin[i]=(isin[i]+1)%2;
if(tp!=ls)
{
a.pb(i);
}
else
{
b.pb(i);
}
ls=tp;
}
find_ans(a,b);
return;
}
Compilation message
minerals.cpp: In function 'void find_ans(std::vector<int>, std::vector<int>)':
minerals.cpp:59:10: warning: 'ch' may be used uninitialized in this function [-Wmaybe-uninitialized]
59 | if(ch!=re)
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
3 ms |
492 KB |
Output is correct |
3 |
Correct |
5 ms |
620 KB |
Output is correct |
4 |
Correct |
10 ms |
876 KB |
Output is correct |
5 |
Correct |
20 ms |
1516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
620 KB |
Output is correct |
8 |
Correct |
10 ms |
876 KB |
Output is correct |
9 |
Correct |
20 ms |
1516 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
13 ms |
1132 KB |
Output is correct |
12 |
Correct |
19 ms |
1536 KB |
Output is correct |
13 |
Correct |
15 ms |
1516 KB |
Output is correct |
14 |
Correct |
17 ms |
1516 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
620 KB |
Output is correct |
8 |
Correct |
10 ms |
876 KB |
Output is correct |
9 |
Correct |
20 ms |
1516 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
13 ms |
1132 KB |
Output is correct |
12 |
Correct |
19 ms |
1536 KB |
Output is correct |
13 |
Correct |
15 ms |
1516 KB |
Output is correct |
14 |
Correct |
17 ms |
1516 KB |
Output is correct |
15 |
Correct |
53 ms |
3436 KB |
Output is correct |
16 |
Correct |
54 ms |
3468 KB |
Output is correct |
17 |
Correct |
42 ms |
3560 KB |
Output is correct |
18 |
Correct |
42 ms |
3248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
620 KB |
Output is correct |
8 |
Correct |
10 ms |
876 KB |
Output is correct |
9 |
Correct |
20 ms |
1516 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
13 ms |
1132 KB |
Output is correct |
12 |
Correct |
19 ms |
1536 KB |
Output is correct |
13 |
Correct |
15 ms |
1516 KB |
Output is correct |
14 |
Correct |
17 ms |
1516 KB |
Output is correct |
15 |
Correct |
53 ms |
3436 KB |
Output is correct |
16 |
Correct |
54 ms |
3468 KB |
Output is correct |
17 |
Correct |
42 ms |
3560 KB |
Output is correct |
18 |
Correct |
42 ms |
3248 KB |
Output is correct |
19 |
Correct |
55 ms |
3436 KB |
Output is correct |
20 |
Correct |
54 ms |
3564 KB |
Output is correct |
21 |
Correct |
43 ms |
3432 KB |
Output is correct |
22 |
Correct |
48 ms |
3308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
620 KB |
Output is correct |
8 |
Correct |
10 ms |
876 KB |
Output is correct |
9 |
Correct |
20 ms |
1516 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
13 ms |
1132 KB |
Output is correct |
12 |
Correct |
19 ms |
1536 KB |
Output is correct |
13 |
Correct |
15 ms |
1516 KB |
Output is correct |
14 |
Correct |
17 ms |
1516 KB |
Output is correct |
15 |
Correct |
53 ms |
3436 KB |
Output is correct |
16 |
Correct |
54 ms |
3468 KB |
Output is correct |
17 |
Correct |
42 ms |
3560 KB |
Output is correct |
18 |
Correct |
42 ms |
3248 KB |
Output is correct |
19 |
Correct |
55 ms |
3436 KB |
Output is correct |
20 |
Correct |
54 ms |
3564 KB |
Output is correct |
21 |
Correct |
43 ms |
3432 KB |
Output is correct |
22 |
Correct |
48 ms |
3308 KB |
Output is correct |
23 |
Correct |
56 ms |
3796 KB |
Output is correct |
24 |
Correct |
58 ms |
3564 KB |
Output is correct |
25 |
Correct |
50 ms |
3560 KB |
Output is correct |
26 |
Correct |
44 ms |
3436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
620 KB |
Output is correct |
8 |
Correct |
10 ms |
876 KB |
Output is correct |
9 |
Correct |
20 ms |
1516 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
13 ms |
1132 KB |
Output is correct |
12 |
Correct |
19 ms |
1536 KB |
Output is correct |
13 |
Correct |
15 ms |
1516 KB |
Output is correct |
14 |
Correct |
17 ms |
1516 KB |
Output is correct |
15 |
Correct |
53 ms |
3436 KB |
Output is correct |
16 |
Correct |
54 ms |
3468 KB |
Output is correct |
17 |
Correct |
42 ms |
3560 KB |
Output is correct |
18 |
Correct |
42 ms |
3248 KB |
Output is correct |
19 |
Correct |
55 ms |
3436 KB |
Output is correct |
20 |
Correct |
54 ms |
3564 KB |
Output is correct |
21 |
Correct |
43 ms |
3432 KB |
Output is correct |
22 |
Correct |
48 ms |
3308 KB |
Output is correct |
23 |
Correct |
56 ms |
3796 KB |
Output is correct |
24 |
Correct |
58 ms |
3564 KB |
Output is correct |
25 |
Correct |
50 ms |
3560 KB |
Output is correct |
26 |
Correct |
44 ms |
3436 KB |
Output is correct |
27 |
Correct |
57 ms |
3692 KB |
Output is correct |
28 |
Correct |
57 ms |
3692 KB |
Output is correct |
29 |
Correct |
44 ms |
3688 KB |
Output is correct |
30 |
Correct |
44 ms |
3564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
620 KB |
Output is correct |
8 |
Correct |
10 ms |
876 KB |
Output is correct |
9 |
Correct |
20 ms |
1516 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
13 ms |
1132 KB |
Output is correct |
12 |
Correct |
19 ms |
1536 KB |
Output is correct |
13 |
Correct |
15 ms |
1516 KB |
Output is correct |
14 |
Correct |
17 ms |
1516 KB |
Output is correct |
15 |
Correct |
53 ms |
3436 KB |
Output is correct |
16 |
Correct |
54 ms |
3468 KB |
Output is correct |
17 |
Correct |
42 ms |
3560 KB |
Output is correct |
18 |
Correct |
42 ms |
3248 KB |
Output is correct |
19 |
Correct |
55 ms |
3436 KB |
Output is correct |
20 |
Correct |
54 ms |
3564 KB |
Output is correct |
21 |
Correct |
43 ms |
3432 KB |
Output is correct |
22 |
Correct |
48 ms |
3308 KB |
Output is correct |
23 |
Correct |
56 ms |
3796 KB |
Output is correct |
24 |
Correct |
58 ms |
3564 KB |
Output is correct |
25 |
Correct |
50 ms |
3560 KB |
Output is correct |
26 |
Correct |
44 ms |
3436 KB |
Output is correct |
27 |
Correct |
57 ms |
3692 KB |
Output is correct |
28 |
Correct |
57 ms |
3692 KB |
Output is correct |
29 |
Correct |
44 ms |
3688 KB |
Output is correct |
30 |
Correct |
44 ms |
3564 KB |
Output is correct |
31 |
Correct |
64 ms |
3820 KB |
Output is correct |
32 |
Correct |
60 ms |
3780 KB |
Output is correct |
33 |
Correct |
46 ms |
3816 KB |
Output is correct |
34 |
Correct |
48 ms |
3692 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
3 ms |
492 KB |
Output is correct |
7 |
Correct |
5 ms |
620 KB |
Output is correct |
8 |
Correct |
10 ms |
876 KB |
Output is correct |
9 |
Correct |
20 ms |
1516 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
13 ms |
1132 KB |
Output is correct |
12 |
Correct |
19 ms |
1536 KB |
Output is correct |
13 |
Correct |
15 ms |
1516 KB |
Output is correct |
14 |
Correct |
17 ms |
1516 KB |
Output is correct |
15 |
Correct |
53 ms |
3436 KB |
Output is correct |
16 |
Correct |
54 ms |
3468 KB |
Output is correct |
17 |
Correct |
42 ms |
3560 KB |
Output is correct |
18 |
Correct |
42 ms |
3248 KB |
Output is correct |
19 |
Correct |
55 ms |
3436 KB |
Output is correct |
20 |
Correct |
54 ms |
3564 KB |
Output is correct |
21 |
Correct |
43 ms |
3432 KB |
Output is correct |
22 |
Correct |
48 ms |
3308 KB |
Output is correct |
23 |
Correct |
56 ms |
3796 KB |
Output is correct |
24 |
Correct |
58 ms |
3564 KB |
Output is correct |
25 |
Correct |
50 ms |
3560 KB |
Output is correct |
26 |
Correct |
44 ms |
3436 KB |
Output is correct |
27 |
Correct |
57 ms |
3692 KB |
Output is correct |
28 |
Correct |
57 ms |
3692 KB |
Output is correct |
29 |
Correct |
44 ms |
3688 KB |
Output is correct |
30 |
Correct |
44 ms |
3564 KB |
Output is correct |
31 |
Correct |
64 ms |
3820 KB |
Output is correct |
32 |
Correct |
60 ms |
3780 KB |
Output is correct |
33 |
Correct |
46 ms |
3816 KB |
Output is correct |
34 |
Correct |
48 ms |
3692 KB |
Output is correct |
35 |
Incorrect |
65 ms |
3820 KB |
Wrong Answer [2] |
36 |
Halted |
0 ms |
0 KB |
- |