This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#include<chrono>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef string str;
typedef bool bl;
typedef vector<ll> vii;
typedef pair<ll,ll> pii;
typedef vector<pii> vpi;
#define ordered_set tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update>
#define fast ios_base::sync_with_stdio(0);cin.tie();
#define test ll qqqqq;cin>>qqqqq;while(qqqqq--)
#define test1 ll qqqqq=1;while(qqqqq--)
#define F first
#define S second
#define forn(i,n) for(int i=0;i<n;i++)
#define forx(i,j,n) for(int i=j;i<n;i++)
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define all(v) v.begin(),v.end()
#define lb lower_bound
#define ub upper_bound
#define pow powww
#define prtll(x) printf("%lld",x)
#define prtld(x) printf("%Lf",x)
#define prtst(x) printf("%s",x)
#define prtch(x) printf("%c",x)
#define measure chrono::high_resolution_clock::now()
#define duration chrono::duration_cast<chrono::milliseconds>(end-start)
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
const ll dx[]{1,0,-1,0,1,-1,1,-1};
const ll dy[]{0,-1,0,1,1,-1,-1,1};
const ll inf=1e18;
const ll mod=1e9+7;
const ll LM=1e8+1;
const ll M=2e5+10;
const ll MM=4002;
const ll MMM=501;
const ld pi=acos(-1);
//const ll mod=998244353;
ll pow(ll r,ll to,ll m=mod){
ll res=1;
r%=m;
while(to){
if((to&1)){
res*=r,res%=m;
}
r*=r,r%=m;
to=(to>>1);
}
return res;
}
ll n,q;
int main(){
fast
//freopen("gen.txt","r",stdin);
auto start=measure;
test1{
cin>>n>>q;
while(q--){
string query;
cin>>query;
if(query.front()=='a'){
ll a;
cin>>a;
vii v;
forn(i,11){
if((a&(1<<i))>0)
v.pb(i);
}
bl r=0;
if(v.size()>5){
vii vv;
forn(i,10){
if(((1<<i)&a)==0)
vv.pb(i);
}
r=1;
v.clear();
v=vv;
}
else if(v.size()==5){
ll s1,s2;
s1=s2=0;
forn(i,10){
if((a&(1<<i))>0)
s2+=i;
else
s1+=i;
}
if(s1<s2){
r=1;
vii vv;
forn(i,10){
if(((1<<i)&a)==0)
vv.pb(i);
}
v.clear();
v=vv;
}
}
vii ans;
if(r){
forn(i,22)
ans.pb(1000);
}
for(auto it:v){
forn(i,it+1)
ans.pb(it+100);
}
cout<<ans.size();
for(auto it:ans)
cout<<' '<<it;
cout<<'\n';
}
else if(query.front()=='b'){
ll a;
cin>>a;
vii v;
forn(i,11){
if((a&(1<<i))>0)
v.pb(i);
}
bl r=0;
if(v.size()>5){
vii vv;
forn(i,10){
if(((1<<i)&a)==0)
vv.pb(i);
}
r=1;
v.clear();
v=vv;
}
else if(v.size()==5){
ll s1,s2;
s1=s2=0;
forn(i,10){
if((a&(1<<i))>0)
s2+=i;
else
s1+=i;
}
if(s1<s2){
r=1;
vii vv;
forn(i,10){
if(((1<<i)&a)==0)
vv.pb(i);
}
v.clear();
v=vv;
}
}
vii ans;
if(r){
forn(i,21)
ans.pb(2000);
}
for(auto it:v){
forn(i,it+11)
ans.pb(it+200);
}
cout<<ans.size();
for(auto it:ans)
cout<<' '<<it;
cout<<'\n';
}
else{
ll c;
cin>>c;
vii v;
ll a=0,b=0;
forn(i,c){
ll x;
cin>>x;
v.pb(x);
}
for(auto it:v){
if(it<=10)
a|=(1<<(it-1));
else if(it<=20){
b|=(1<<(it-11));
}
else if(it==21)
b=(((1<<10)-1)^b);
else
a=(((1<<10)-1)^a);
}
if(a>b)
cout<<"A\n";
else
cout<<"B\n";
}
}
}
auto end=measure;
auto dur=duration;
//cout<<fixed<<dur.count()<<'\n';
return 0;
}
/*
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |