#include <bits/stdc++.h>
#include <algorithm>
#include <chrono>
#include <iostream>
#include <random>
#include <vector>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
#include "minerals.h"
mt19937 rndm(chrono::steady_clock::now().time_since_epoch().count());
const int N=2e5+99;
int n,last,prt,Q,dft,a[N],s[N],t[N],L[N],R[N],tof[N],mark[N];
vector<pair<int,int>> Ans;
vector<int> pos,A,B;
/*
void Answer(int a, int b){
//cout<<a<<" edge "<<b<<endl;
}
int Query(int x){
Q++;
if(mark[x]==1) dft+=(mark[a[x]]==0);
else dft-=(mark[a[x]]==0);
//cout<<"? "<<x<<" "<<res<<endl;
return dft;
}
*/
bool ask(int x){
mark[x]^=1;
int p=Query(x),res=(p!=last);
last=p;
return res;
}
void get(int l,int r){
for(auto x : pos){
if(x<l || r<=x){
prt++;
ask(B[x]);
}
}
pos.clear();
f(i,l,r){
pos.pb(i);
if(!mark[B[i]]) ask(B[i]),prt++;
}
//cout<<l<<" "<<r<<" "<<prt<<endl;
}
void solve(int l,int r,vector<int> &vec){
//cout<<l<<" "<<r<<endl;
shuffle(all(vec),rndm);
if(l+1==r){
Ans.pb({vec[0],B[l]});
return ;
}
vector<int> a,b;
int mid=(l+r+1)>>1;
get(l,mid);
for(auto x : vec){
if(a.size()!=mid-l && (b.size()==r-mid || ask(x)==0)) a.pb(x);
else b.pb(x);
}
solve(l,mid,a);
solve(mid,r,b);
}
void Solve(int N){
n=N;
vector<int> p(2*n);
iota(all(p),1);
shuffle(all(p),rndm);
f(i,0,2*n){
if(ask(p[i])){
A.pb(p[i]);
tof[p[i]]=B.size();
}
else B.pb(p[i]);
}
//dbgv(A);
f(i,0,n) pos.pb(i);
solve(0,n,A);
for(auto p : Ans){
Answer(p.F,p.S);
}
}
/*
4
1 4
2 5
3 6
7 8
prt1=656454
prt2=
*/
/*
main(){
int n;
cin>>n;
f(i,1,n+1){
s[i]=i,t[i]=i+n;
//cin>>s[i]>>t[i];
a[s[i]]=t[i];
a[t[i]]=s[i];
}
Solve(n);
eror(prt);
eror(Q);
}
*/
Compilation message
minerals.cpp: In function 'void solve(int, int, std::vector<int>&)':
minerals.cpp:79:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
79 | if(a.size()!=mid-l && (b.size()==r-mid || ask(x)==0)) a.pb(x);
| ~~~~~~~~^~~~~~~
minerals.cpp:79:34: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
79 | if(a.size()!=mid-l && (b.size()==r-mid || ask(x)==0)) a.pb(x);
| ~~~~~~~~^~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
3 ms |
456 KB |
Output is correct |
3 |
Correct |
4 ms |
584 KB |
Output is correct |
4 |
Correct |
8 ms |
968 KB |
Output is correct |
5 |
Correct |
16 ms |
1584 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
456 KB |
Output is correct |
7 |
Correct |
4 ms |
584 KB |
Output is correct |
8 |
Correct |
8 ms |
968 KB |
Output is correct |
9 |
Correct |
16 ms |
1584 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
11 ms |
1224 KB |
Output is correct |
12 |
Correct |
19 ms |
1600 KB |
Output is correct |
13 |
Correct |
16 ms |
1588 KB |
Output is correct |
14 |
Correct |
16 ms |
1592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
456 KB |
Output is correct |
7 |
Correct |
4 ms |
584 KB |
Output is correct |
8 |
Correct |
8 ms |
968 KB |
Output is correct |
9 |
Correct |
16 ms |
1584 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
11 ms |
1224 KB |
Output is correct |
12 |
Correct |
19 ms |
1600 KB |
Output is correct |
13 |
Correct |
16 ms |
1588 KB |
Output is correct |
14 |
Correct |
16 ms |
1592 KB |
Output is correct |
15 |
Correct |
68 ms |
3592 KB |
Output is correct |
16 |
Correct |
53 ms |
3812 KB |
Output is correct |
17 |
Correct |
44 ms |
3832 KB |
Output is correct |
18 |
Correct |
49 ms |
3388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
456 KB |
Output is correct |
7 |
Correct |
4 ms |
584 KB |
Output is correct |
8 |
Correct |
8 ms |
968 KB |
Output is correct |
9 |
Correct |
16 ms |
1584 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
11 ms |
1224 KB |
Output is correct |
12 |
Correct |
19 ms |
1600 KB |
Output is correct |
13 |
Correct |
16 ms |
1588 KB |
Output is correct |
14 |
Correct |
16 ms |
1592 KB |
Output is correct |
15 |
Correct |
68 ms |
3592 KB |
Output is correct |
16 |
Correct |
53 ms |
3812 KB |
Output is correct |
17 |
Correct |
44 ms |
3832 KB |
Output is correct |
18 |
Correct |
49 ms |
3388 KB |
Output is correct |
19 |
Correct |
48 ms |
3684 KB |
Output is correct |
20 |
Correct |
51 ms |
3992 KB |
Output is correct |
21 |
Correct |
57 ms |
3768 KB |
Output is correct |
22 |
Correct |
53 ms |
3636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
456 KB |
Output is correct |
7 |
Correct |
4 ms |
584 KB |
Output is correct |
8 |
Correct |
8 ms |
968 KB |
Output is correct |
9 |
Correct |
16 ms |
1584 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
11 ms |
1224 KB |
Output is correct |
12 |
Correct |
19 ms |
1600 KB |
Output is correct |
13 |
Correct |
16 ms |
1588 KB |
Output is correct |
14 |
Correct |
16 ms |
1592 KB |
Output is correct |
15 |
Correct |
68 ms |
3592 KB |
Output is correct |
16 |
Correct |
53 ms |
3812 KB |
Output is correct |
17 |
Correct |
44 ms |
3832 KB |
Output is correct |
18 |
Correct |
49 ms |
3388 KB |
Output is correct |
19 |
Correct |
48 ms |
3684 KB |
Output is correct |
20 |
Correct |
51 ms |
3992 KB |
Output is correct |
21 |
Correct |
57 ms |
3768 KB |
Output is correct |
22 |
Correct |
53 ms |
3636 KB |
Output is correct |
23 |
Correct |
49 ms |
3768 KB |
Output is correct |
24 |
Correct |
49 ms |
3740 KB |
Output is correct |
25 |
Correct |
54 ms |
3972 KB |
Output is correct |
26 |
Correct |
51 ms |
3712 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
456 KB |
Output is correct |
7 |
Correct |
4 ms |
584 KB |
Output is correct |
8 |
Correct |
8 ms |
968 KB |
Output is correct |
9 |
Correct |
16 ms |
1584 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
11 ms |
1224 KB |
Output is correct |
12 |
Correct |
19 ms |
1600 KB |
Output is correct |
13 |
Correct |
16 ms |
1588 KB |
Output is correct |
14 |
Correct |
16 ms |
1592 KB |
Output is correct |
15 |
Correct |
68 ms |
3592 KB |
Output is correct |
16 |
Correct |
53 ms |
3812 KB |
Output is correct |
17 |
Correct |
44 ms |
3832 KB |
Output is correct |
18 |
Correct |
49 ms |
3388 KB |
Output is correct |
19 |
Correct |
48 ms |
3684 KB |
Output is correct |
20 |
Correct |
51 ms |
3992 KB |
Output is correct |
21 |
Correct |
57 ms |
3768 KB |
Output is correct |
22 |
Correct |
53 ms |
3636 KB |
Output is correct |
23 |
Correct |
49 ms |
3768 KB |
Output is correct |
24 |
Correct |
49 ms |
3740 KB |
Output is correct |
25 |
Correct |
54 ms |
3972 KB |
Output is correct |
26 |
Correct |
51 ms |
3712 KB |
Output is correct |
27 |
Correct |
56 ms |
4020 KB |
Output is correct |
28 |
Correct |
65 ms |
3836 KB |
Output is correct |
29 |
Correct |
48 ms |
3800 KB |
Output is correct |
30 |
Correct |
50 ms |
3656 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
456 KB |
Output is correct |
7 |
Correct |
4 ms |
584 KB |
Output is correct |
8 |
Correct |
8 ms |
968 KB |
Output is correct |
9 |
Correct |
16 ms |
1584 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
11 ms |
1224 KB |
Output is correct |
12 |
Correct |
19 ms |
1600 KB |
Output is correct |
13 |
Correct |
16 ms |
1588 KB |
Output is correct |
14 |
Correct |
16 ms |
1592 KB |
Output is correct |
15 |
Correct |
68 ms |
3592 KB |
Output is correct |
16 |
Correct |
53 ms |
3812 KB |
Output is correct |
17 |
Correct |
44 ms |
3832 KB |
Output is correct |
18 |
Correct |
49 ms |
3388 KB |
Output is correct |
19 |
Correct |
48 ms |
3684 KB |
Output is correct |
20 |
Correct |
51 ms |
3992 KB |
Output is correct |
21 |
Correct |
57 ms |
3768 KB |
Output is correct |
22 |
Correct |
53 ms |
3636 KB |
Output is correct |
23 |
Correct |
49 ms |
3768 KB |
Output is correct |
24 |
Correct |
49 ms |
3740 KB |
Output is correct |
25 |
Correct |
54 ms |
3972 KB |
Output is correct |
26 |
Correct |
51 ms |
3712 KB |
Output is correct |
27 |
Correct |
56 ms |
4020 KB |
Output is correct |
28 |
Correct |
65 ms |
3836 KB |
Output is correct |
29 |
Correct |
48 ms |
3800 KB |
Output is correct |
30 |
Correct |
50 ms |
3656 KB |
Output is correct |
31 |
Incorrect |
54 ms |
3704 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
0 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
3 ms |
456 KB |
Output is correct |
7 |
Correct |
4 ms |
584 KB |
Output is correct |
8 |
Correct |
8 ms |
968 KB |
Output is correct |
9 |
Correct |
16 ms |
1584 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
11 ms |
1224 KB |
Output is correct |
12 |
Correct |
19 ms |
1600 KB |
Output is correct |
13 |
Correct |
16 ms |
1588 KB |
Output is correct |
14 |
Correct |
16 ms |
1592 KB |
Output is correct |
15 |
Correct |
68 ms |
3592 KB |
Output is correct |
16 |
Correct |
53 ms |
3812 KB |
Output is correct |
17 |
Correct |
44 ms |
3832 KB |
Output is correct |
18 |
Correct |
49 ms |
3388 KB |
Output is correct |
19 |
Correct |
48 ms |
3684 KB |
Output is correct |
20 |
Correct |
51 ms |
3992 KB |
Output is correct |
21 |
Correct |
57 ms |
3768 KB |
Output is correct |
22 |
Correct |
53 ms |
3636 KB |
Output is correct |
23 |
Correct |
49 ms |
3768 KB |
Output is correct |
24 |
Correct |
49 ms |
3740 KB |
Output is correct |
25 |
Correct |
54 ms |
3972 KB |
Output is correct |
26 |
Correct |
51 ms |
3712 KB |
Output is correct |
27 |
Correct |
56 ms |
4020 KB |
Output is correct |
28 |
Correct |
65 ms |
3836 KB |
Output is correct |
29 |
Correct |
48 ms |
3800 KB |
Output is correct |
30 |
Correct |
50 ms |
3656 KB |
Output is correct |
31 |
Incorrect |
54 ms |
3704 KB |
Wrong Answer [2] |
32 |
Halted |
0 ms |
0 KB |
- |