#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;
// printf("%d %d\n",A.size(),B.size());
// for(int i=0;i<A.size();i++)
// {
// printf("%d ",A[i]);
// }
// printf("\n");
// for(int i=0;i<B.size();i++)
// {
// printf("%d ",B[i]);
// }
// printf("\n");
// printf("===========\n");
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++)
{
re=Query(A[i]);
isin[A[i]]=(isin[A[i]]+1)%2;
if(ch!=re)
{
na2.pb(A[i]);
}
else
{
na1.pb(A[i]);
}
}
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:60:9: warning: 'ch' may be used uninitialized in this function [-Wmaybe-uninitialized]
60 | if(ch!=re)
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
161 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
364 KB |
Wrong Answer [5] |
2 |
Halted |
0 ms |
0 KB |
- |