QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#289007 | #7863. Parity Game | ucup-team266# | WA | 1ms | 3392kb | C++20 | 3.4kb | 2023-12-23 14:43:07 | 2023-12-23 14:43:07 |
Judging History
answer
/*
Things to notice:
1. do not calculate useless values
2. do not use similar names
Things to check:
1. submit the correct file
2. time (it is log^2 or log)
3. memory
4. prove your naive thoughts
5. long long
6. corner case like n=0,1,inf or n=m
7. check if there is a mistake in the ds or other tools you use
8. fileio in some oi-contest
9. module on time
10. the number of a same divisor in a math problem
11. multi-information and queries for dp and ds problems
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
const int mod=998244353;
const int inf=0x3f3f3f3f;
int n,T;
vector <int> a;
void era(int x)
{
if(a[x]==1)
{
if(x+1<=n) cout<<x<<" *\n";
else cout<<x-1<<" *\n";
fflush(stdout);
a.erase(a.begin()+x);
}
else
{
if(x+1<=n) cout<<x<<" +\n";
else cout<<x-1<<" +\n";
fflush(stdout);
a.erase(a.begin()+x);
}
n--;
}
void Alice0()
{
cout<<"Alice\n";
fflush(stdout);
int op=0;
while(n>1)
{
if(op==0)
{
int flg=0;
for(int i=1;i<n;i++) if(a[i]==1&&a[i+1]==1)
{
cout<<i<<" "<<"+\n";
fflush(stdout);
flg=1;
a.erase(a.begin()+i),n--;
a[i]=0;
break;
}
if(!flg)
{
int del=1;
for(int i=1;i<=n;i++) if(a[i]==1) del=i;
era(del);
}
}
else
{
int x;
cin>>x;
char o;
cin>>o;
if(o=='+') a[x]=(a[x]+a[x+1])%2,a.erase(a.begin()+x+1);
else a[x]=a[x]*a[x+1],a.erase(a.begin()+x+1);
n--;
}
op^=1;
}
}
void Bob0()
{
cout<<"Bob\n";
fflush(stdout);
int op=1;
int lstpos=-1;
while(n>1)
{
if(op==0)
{
// cout<<"... "<<lstpos<<"\n";
era(lstpos);
}
else
{
int x;
cin>>x;
char o;
cin>>o;
if(o=='+') a[x]=(a[x]+a[x+1])%2,a.erase(a.begin()+x+1);
else a[x]=a[x]*a[x+1],a.erase(a.begin()+x+1);
n--;
lstpos=x;
}
op^=1;
}
}
void Bob1()
{
cout<<"Bob\n";
fflush(stdout);
int op=1;
while(n>1)
{
if(op==0)
{
int flg=0;
for(int i=1;i<n;i++) if(a[i]==1&&a[i+1]==1)
{
cout<<i<<" "<<"+\n";
fflush(stdout);
flg=1;
a.erase(a.begin()+i),n--;
a[i]=0;
break;
}
if(!flg)
{
int del=1;
for(int i=1;i<=n;i++) if(a[i]==1) del=i;
era(del);
}
}
else
{
int x;
cin>>x;
char o;
cin>>o;
if(o=='+') a[x]=(a[x]+a[x+1])%2,a.erase(a.begin()+x+1);
else a[x]=a[x]*a[x+1],a.erase(a.begin()+x+1);
n--;
}
op^=1;
}
}
void Alice1()
{
cout<<"Alice\n";
fflush(stdout);
int p=1;
int lstpos=-1;
for(int i=1;i<=n;i++) if(a[i]) p=i;
era(p);
int op=1;
while(n>1)
{
if(op==0)
{
era(lstpos);
}
else
{
int x;
cin>>x;
char o;
cin>>o;
if(o=='+') a[x]=(a[x]+a[x+1])%2,a.erase(a.begin()+x+1);
else a[x]=a[x]*a[x+1],a.erase(a.begin()+x+1);
n--;
lstpos=x;
}
op^=1;
}
}
void solve()
{
cin>>n>>T;
a.pb(-1);
int c0=0,c1=0;
for(int i=1;i<=n;i++)
{
int x;
cin>>x;
a.pb(x);
if(x==0) c0++;
else c1++;
}
if(T==0)
{
if(c0) Alice0();
else if(c1%2==0) Alice0();
else Bob0();
}
else
{
if(c0>=2) Bob1();
else if(c0==0)
{
if(c1%2==1) Bob1();
else Alice1();
}
else
{
if(c1%2==1) Alice1();
else Bob1();
}
}
}
signed main()
{
// ios::sync_with_stdio(0);
// cin.tie(0);
int _=1;
// cin>>_;
while(_--) solve();
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3392kb
input:
4 1 0 1 0 1 1 + 1 + 0
output:
Bob 2 *
result:
wrong answer The interactor wins!