#include <bits/stdc++.h>
#include "minerals.h"
#define int LL //__int128
#define double long double
using namespace std;
using LL=long long;
using uLL=unsigned long long;
using pii=pair<LL,LL>;
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fors(i,a,b,s) for(int i=a;i<=b;i+=s)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define L(id) (id*2+1)
#define R(id) (id*2+2)
#define LO(x) (x&(-x))
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define mkp make_pair
#define MOD (int)(1000000007)
#define INF (int)(1000000000000000ll) //1e15
#define EPS (1e-6)
#ifdef NYAOWO
#include "debug.hpp"
inline void USACO(const string &s) { cerr<<"USACO: "<<s<<"\n"; }
#else
#define debug(...)
inline void timer(){}
inline void USACO(const string &s){
freopen((s+".in").c_str(),"r",stdin);
freopen((s+".out").c_str(),"w",stdout);
}
#endif
inline void NYA() { ios::sync_with_stdio(false); cin.tie(0); }
inline int gcd(int a,int b) { return __gcd(a,b); }
inline int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p,const int &mod){
int ans=1;
while(p){
if(p&1) ans=ans*b%mod;
p/=2; b=b*b%mod;
}
return ans;
}
int fpow(int b,int p) { return fpow(b,p,MOD); }
template<typename T> inline void chmin(T &_a,const T &_b) { if(_b<_a) _a=_b; }
template<typename T> inline void chmax(T &_a,const T &_b) { if(_b>_a) _a=_b; }
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
struct Interactor{
bitset<90000> bs;
int last=0;
void init(){
bs.reset();
}
bool push(int x){
bool ans=false;
if(!bs[x]){
int now=Query(x);
bs[x]=true;
ans=(now!=last);
last=now;
}
return ans;
}
bool pop(int x){
bool ans=false;
if(bs[x]){
int now=Query(x);
bs[x]=false;
ans=(now!=last);
last=now;
}
return ans;
}
bool toggle(int x){
int now=Query(x);
bs[x]=!bs[x];
bool ans=(now==last);
last=now;
return ans;
}
}inter;
void solve(vector<int> &vl,vector<int> &vr,int l,int r,bool fill){
//debug(vl,vr,l,r,fill);
if(sz(vl)==1){
Answer(vl[0],vr[l]);
return;
}
int n=max(1ll,sz(vl)/3);
For(i,l,l+n-1) inter.toggle(vr[i]);
vector<int> vll,vlr;
for(auto &i:vl){
bool res=inter.toggle(i);
if(fill!=res) vll.eb(i);
else vlr.eb(i);
}
solve(vll,vr,l,l+n-1,!fill);
solve(vlr,vr,l+n,r,fill);
}
void Solve(int32_t n){
vector<int> l,r;
For(i,1,n*2){
if(inter.toggle(i)) l.eb(i);
else r.eb(i);
}
solve(l,r,0,n-1,true);
// vector<int> t(n);
// For(pos,0,15){
// For(i,0,n-1){
// if((i&(1<<pos))==0) inter.push(r[i]);
// else inter.pop(r[i]);
// }
// int now=0;
// For(i,0,n-1){
// if(!inter.toggle(l[i])){
// t[now]=l[i];
// now++;
// l[i]=0;
// }
// }
// For(i,0,n-1) if(l[i]!=0){
// t[now]=l[i];
// now++;
// }
// assert(now==n);
// l.swap(t);
// }
// For(i,0,n-1) Answer(l[i],r[i]);
}
// void Solve(int32_t N) {
// int v = Query(1);
// for (int i = 1; i <= N; ++i) {
// Answer(i, 2 * N + 1 - i);
// }
// }
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
2 ms |
456 KB |
Output is correct |
3 |
Correct |
3 ms |
584 KB |
Output is correct |
4 |
Correct |
5 ms |
840 KB |
Output is correct |
5 |
Correct |
9 ms |
1360 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
456 KB |
Output is correct |
7 |
Correct |
3 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
840 KB |
Output is correct |
9 |
Correct |
9 ms |
1360 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
7 ms |
968 KB |
Output is correct |
12 |
Correct |
11 ms |
1432 KB |
Output is correct |
13 |
Correct |
9 ms |
1368 KB |
Output is correct |
14 |
Correct |
8 ms |
1352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
456 KB |
Output is correct |
7 |
Correct |
3 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
840 KB |
Output is correct |
9 |
Correct |
9 ms |
1360 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
7 ms |
968 KB |
Output is correct |
12 |
Correct |
11 ms |
1432 KB |
Output is correct |
13 |
Correct |
9 ms |
1368 KB |
Output is correct |
14 |
Correct |
8 ms |
1352 KB |
Output is correct |
15 |
Correct |
26 ms |
3136 KB |
Output is correct |
16 |
Correct |
33 ms |
3144 KB |
Output is correct |
17 |
Correct |
21 ms |
3028 KB |
Output is correct |
18 |
Correct |
22 ms |
3004 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
456 KB |
Output is correct |
7 |
Correct |
3 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
840 KB |
Output is correct |
9 |
Correct |
9 ms |
1360 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
7 ms |
968 KB |
Output is correct |
12 |
Correct |
11 ms |
1432 KB |
Output is correct |
13 |
Correct |
9 ms |
1368 KB |
Output is correct |
14 |
Correct |
8 ms |
1352 KB |
Output is correct |
15 |
Correct |
26 ms |
3136 KB |
Output is correct |
16 |
Correct |
33 ms |
3144 KB |
Output is correct |
17 |
Correct |
21 ms |
3028 KB |
Output is correct |
18 |
Correct |
22 ms |
3004 KB |
Output is correct |
19 |
Correct |
27 ms |
3116 KB |
Output is correct |
20 |
Correct |
27 ms |
3188 KB |
Output is correct |
21 |
Correct |
23 ms |
3124 KB |
Output is correct |
22 |
Correct |
23 ms |
2980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
456 KB |
Output is correct |
7 |
Correct |
3 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
840 KB |
Output is correct |
9 |
Correct |
9 ms |
1360 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
7 ms |
968 KB |
Output is correct |
12 |
Correct |
11 ms |
1432 KB |
Output is correct |
13 |
Correct |
9 ms |
1368 KB |
Output is correct |
14 |
Correct |
8 ms |
1352 KB |
Output is correct |
15 |
Correct |
26 ms |
3136 KB |
Output is correct |
16 |
Correct |
33 ms |
3144 KB |
Output is correct |
17 |
Correct |
21 ms |
3028 KB |
Output is correct |
18 |
Correct |
22 ms |
3004 KB |
Output is correct |
19 |
Correct |
27 ms |
3116 KB |
Output is correct |
20 |
Correct |
27 ms |
3188 KB |
Output is correct |
21 |
Correct |
23 ms |
3124 KB |
Output is correct |
22 |
Correct |
23 ms |
2980 KB |
Output is correct |
23 |
Correct |
28 ms |
3192 KB |
Output is correct |
24 |
Correct |
28 ms |
3152 KB |
Output is correct |
25 |
Correct |
24 ms |
3188 KB |
Output is correct |
26 |
Correct |
23 ms |
3284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
456 KB |
Output is correct |
7 |
Correct |
3 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
840 KB |
Output is correct |
9 |
Correct |
9 ms |
1360 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
7 ms |
968 KB |
Output is correct |
12 |
Correct |
11 ms |
1432 KB |
Output is correct |
13 |
Correct |
9 ms |
1368 KB |
Output is correct |
14 |
Correct |
8 ms |
1352 KB |
Output is correct |
15 |
Correct |
26 ms |
3136 KB |
Output is correct |
16 |
Correct |
33 ms |
3144 KB |
Output is correct |
17 |
Correct |
21 ms |
3028 KB |
Output is correct |
18 |
Correct |
22 ms |
3004 KB |
Output is correct |
19 |
Correct |
27 ms |
3116 KB |
Output is correct |
20 |
Correct |
27 ms |
3188 KB |
Output is correct |
21 |
Correct |
23 ms |
3124 KB |
Output is correct |
22 |
Correct |
23 ms |
2980 KB |
Output is correct |
23 |
Correct |
28 ms |
3192 KB |
Output is correct |
24 |
Correct |
28 ms |
3152 KB |
Output is correct |
25 |
Correct |
24 ms |
3188 KB |
Output is correct |
26 |
Correct |
23 ms |
3284 KB |
Output is correct |
27 |
Incorrect |
28 ms |
3288 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
456 KB |
Output is correct |
7 |
Correct |
3 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
840 KB |
Output is correct |
9 |
Correct |
9 ms |
1360 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
7 ms |
968 KB |
Output is correct |
12 |
Correct |
11 ms |
1432 KB |
Output is correct |
13 |
Correct |
9 ms |
1368 KB |
Output is correct |
14 |
Correct |
8 ms |
1352 KB |
Output is correct |
15 |
Correct |
26 ms |
3136 KB |
Output is correct |
16 |
Correct |
33 ms |
3144 KB |
Output is correct |
17 |
Correct |
21 ms |
3028 KB |
Output is correct |
18 |
Correct |
22 ms |
3004 KB |
Output is correct |
19 |
Correct |
27 ms |
3116 KB |
Output is correct |
20 |
Correct |
27 ms |
3188 KB |
Output is correct |
21 |
Correct |
23 ms |
3124 KB |
Output is correct |
22 |
Correct |
23 ms |
2980 KB |
Output is correct |
23 |
Correct |
28 ms |
3192 KB |
Output is correct |
24 |
Correct |
28 ms |
3152 KB |
Output is correct |
25 |
Correct |
24 ms |
3188 KB |
Output is correct |
26 |
Correct |
23 ms |
3284 KB |
Output is correct |
27 |
Incorrect |
28 ms |
3288 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
328 KB |
Output is correct |
6 |
Correct |
2 ms |
456 KB |
Output is correct |
7 |
Correct |
3 ms |
584 KB |
Output is correct |
8 |
Correct |
5 ms |
840 KB |
Output is correct |
9 |
Correct |
9 ms |
1360 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
7 ms |
968 KB |
Output is correct |
12 |
Correct |
11 ms |
1432 KB |
Output is correct |
13 |
Correct |
9 ms |
1368 KB |
Output is correct |
14 |
Correct |
8 ms |
1352 KB |
Output is correct |
15 |
Correct |
26 ms |
3136 KB |
Output is correct |
16 |
Correct |
33 ms |
3144 KB |
Output is correct |
17 |
Correct |
21 ms |
3028 KB |
Output is correct |
18 |
Correct |
22 ms |
3004 KB |
Output is correct |
19 |
Correct |
27 ms |
3116 KB |
Output is correct |
20 |
Correct |
27 ms |
3188 KB |
Output is correct |
21 |
Correct |
23 ms |
3124 KB |
Output is correct |
22 |
Correct |
23 ms |
2980 KB |
Output is correct |
23 |
Correct |
28 ms |
3192 KB |
Output is correct |
24 |
Correct |
28 ms |
3152 KB |
Output is correct |
25 |
Correct |
24 ms |
3188 KB |
Output is correct |
26 |
Correct |
23 ms |
3284 KB |
Output is correct |
27 |
Incorrect |
28 ms |
3288 KB |
Wrong Answer [2] |
28 |
Halted |
0 ms |
0 KB |
- |