QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#350962 | #7863. Parity Game | chenxinyang2006 | WA | 2ms | 3932kb | C++14 | 2.9kb | 2024-03-11 10:59:07 | 2024-03-11 10:59:07 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<=(k);i++)
#define per(i,j,k) for(int i=(j);i>=(k);i--)
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mkp make_pair
#define eb emplace_back
#define SZ(S) (int)S.size()
//#define mod 998244353
//#define mod 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f
using namespace std;
template <class T>
void chkmax(T &x,T y){
if(x < y) x = y;
}
template <class T>
void chkmin(T &x,T y){
if(x > y) x = y;
}
inline int popcnt(int x){
return __builtin_popcount(x);
}
inline int ctz(int x){
return __builtin_ctz(x);
}
/*ll power(ll p,int k = mod - 2){
ll ans = 1;
while(k){
if(k % 2 == 1) ans = ans * p % mod;
p = p * p % mod;
k /= 2;
}
return ans;
}*/
int n,t;
int a[505],b[505];
void oper(int pos,char op){
assert(1 <= pos && pos < n);
rep(i,1,pos - 1) b[i] = a[i];
if(op == '+') b[pos] = a[pos] ^ a[pos + 1];
else b[pos] = a[pos] & b[pos + 1];
rep(i,pos + 1,n - 1) b[i] = a[i + 1];
n--;
rep(i,1,n) a[i] = b[i];
}
void oper_(int pos,char op){
printf("%d %c\n",pos,op);
fflush(stdout);
oper(pos,op);
}
int main(){
scanf("%d%d",&n,&t);
rep(i,1,n) scanf("%d",&a[i]);
int play,sp;//=0 self
if(n % 2 == t){
if(n % 2 == 0) play = 0;
else play = 1;
sp = -1;
}else{
int cst = 0;
for(int l = 1,r;l <= n;l = r + 1){
r = l;
while(r < n && a[r + 1] == a[r]) r++;
if(!a[l]) continue;
cst += (r - l) / 2 + 1;
}
// printf("cst=%d\n",cst);
if(cst <= (n + 1) / 2 - 1){
if(n % 2 == 0) play = 1;
else play = 0;
sp = 1;
}else{
if(n % 2 == 0) play = 0;
else play = 1;
sp = 0;
}
}
if(!play) printf("Alice\n");
else printf("Bob\n");
fflush(stdout);
int ok;
while(n > 1){
if(!play){
if(sp == -1){
if(n == 2){
if(!a[1] || !a[2]) oper_(1,'*');
else oper_(1,'+');
}else{
oper_(1,'+');
}
}else if(!sp){
if(!a[1]){
oper_(1,'+');
}else if(!a[n]){
oper_(n - 1,'+');
}else{
ok = 0;
for(int l = 1,r;l <= n;l = r + 1){
r = l;
while(r < n && a[r] == a[r + 1]) r++;
if(!a[l]){
if(r > l){
ok = 1;
oper_(l,'+');
break;
}
continue;
}
if(l % 2 != r % 2){
ok = 1;
oper_(l,'*');
break;
}
}
if(!ok) oper_(n - 1,'*');
}
}else{
ok = 0;
for(int l = 1,r;l <= n;l = r + 1){
r = l;
while(r < n && a[r] == a[r + 1]) r++;
if(!a[l]) continue;
oper_(l,'+');
ok = 1;
break;
}
if(!ok) oper_(1,'+');
}
}else{
int pos;
char str[233];
scanf("%d%s",&pos,str + 1);
oper(pos,str[1]);
}
play ^= 1;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3804kb
input:
4 1 0 1 0 1 1 * 1
output:
Alice 1 + 1 +
result:
ok The player wins!
Test #2:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
4 0 1 0 1 0 1 * 1
output:
Alice 1 + 1 *
result:
ok The player wins!
Test #3:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
5 1 1 1 1 0 0 4 + 1 + 1
output:
Bob 1 + 1 *
result:
ok The player wins!
Test #4:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
3 0 1 1 1 1 + 1
output:
Bob 1 +
result:
ok The player wins!
Test #5:
score: 0
Accepted
time: 0ms
memory: 3932kb
input:
3 1 1 0 1 1 * 1
output:
Bob 1 *
result:
ok The player wins!
Test #6:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
3 0 1 0 1 1 * 1
output:
Bob 1 +
result:
ok The player wins!
Test #7:
score: 0
Accepted
time: 1ms
memory: 3896kb
input:
2 1 0 1 1
output:
Alice 1 +
result:
ok The player wins!
Test #8:
score: -100
Wrong Answer
time: 2ms
memory: 3892kb
input:
499 0 0 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 0 1 0 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 1 0 1 0 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 1 1 1 0 1 1 1 1 1 1 1 0 1 0 ...
output:
Alice 2 + 2 + 2 + 2 + 1 + 1 + 2 + 2 + 1 + 2 + 2 + 1 + 1 + 1 + 2 + 2 + 2 + 1 + 1 + 2 + 1 + 1 + 1 + 1 + 1 + 2 + 2 + 2 + 1 + 1 + 1 + 2 + 2 + 2 + 2 + 1 + 1 + 1 + 1 + 1 + 2 + 2 + 2 + 2 + 1 + 1 + 1 + 2 + 2 + 1 + 1 + 2 + 2 + 1 + 1 + 1 + 2 + 1 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 2 + 1 + 1 + 2 + 2 + 2 + 2 + 1 + 2 ...
result:
wrong answer The interactor wins!