QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#342629 | #7863. Parity Game | goodier | WA | 0ms | 3920kb | C++17 | 4.9kb | 2024-03-01 13:57:43 | 2024-03-01 13:57:43 |
Judging History
answer
#include <bits/stdc++.h>
#define ffl fflush(stdout)
using namespace std;
const int N = 550;
int a[N], ba[N], n, t;
void Del(int x, int n)
{
for(int i = x; i < n; i++)
{
a[i] = a[i + 1];
}
}
int valid0()
{
for(int len = n; len >= 2; len--)
{
if(((n - len) & 1) ^ t ^ 1)
{
int flag = 0;
for(int i = 1; i < len; i++)
{
if(a[i] == a[i + 1] && a[i] == 1)
{
Del(i, len);
a[i] = 0;
flag = 1;
break;
}
}
if(!flag)
{
for(int i = 1; i <= len; i++)
{
if(a[i] == 1)
{
Del(i, len);
flag = 1;
break;
}
}
}
if(!flag)
{
Del(1, len);
}
}
else
{
int flag = 0;
for(int i = 1; i <= len; i++)
{
if(a[i] == 0)
{
Del(i, len);
flag = 1;
break;
}
}
if(!flag)
{
Del(2, len);
}
}
}
return a[1] == 0;
}
int main()
{
//freopen("data.in", "r", stdin);
scanf("%d%d", &n, &t);
int len = 0, res0 = 0, res1 = 0;
for(int i = 1; i <= n; i++)
{
scanf("%d", &a[i]);
ba[i] = a[i];
}
int flag0 = 0;
if(valid0())
{
flag0 = 1;
}
memcpy(a, ba, sizeof(a));
if(flag0)
{
if(!t) puts("Alice");
else puts("Bob");
ffl;
for(int len = n; len >= 2; len--)
{
if(((n - len) & 1) ^ t ^ 1)
{
int flag = 0;
for(int i = 1; i < len; i++)
{
if(a[i] == a[i + 1] && a[i] == 1)
{
printf("%d +\n", i);
ffl;
Del(i, len);
a[i] = 0;
flag = 1;
break;
}
}
if(!flag)
{
for(int i = 1; i <= len; i++)
{
if(a[i] == 1)
{
printf("%d *\n", i - (i == len));
ffl;
Del(i, len);
flag = 1;
break;
}
}
}
if(!flag)
{
puts("1 *");
ffl;
Del(1, len);
}
}
else
{
char str[2]; int x;
scanf("%d%s", &x, str);
if(str[0] == '*')
{
a[x] &= a[x + 1];
}
else if(str[0] == '+')
{
int v = (a[x] + a[x + 1]) & 1;
a[x] = v;
}
Del(x + 1, len);
}
}
}
else
{
if(n & 1) puts("Bob");
else puts("Alice");
ffl;
for(int len = n; len >= 3; len--)
{
if(((n - len) & 1) ^ (n & 1) ^ 1)
{
int flag = 0;
for(int i = 1; i <= len; i++)
{
if(a[i] == 0)
{
printf("%d +\n", i - (i == len));
ffl;
Del(i, len);
flag = 1;
break;
}
}
if(!flag)
{
puts("1 *");
ffl;
Del(2, len);
}
}
else
{
char str[2]; int x;
//exit(0);
scanf("%d%s", &x, str);
if(str[0] == '*')
{
a[x] &= a[x + 1];
}
else
{
int v = (a[x] + a[x + 1]) & 1;
a[x] = v;
}
Del(x + 1, len);
}
}
if(a[1] + a[2] == 1)
{
if((n & 1) ^ t) puts("1 +");
else puts("1 *");
ffl;
}
else
{
if((n & 1) ^ t) puts("1 *");
else puts("1 +");
ffl;
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3920kb
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: 3848kb
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: 3788kb
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: 3740kb
input:
3 0 1 1 1 1 + 1
output:
Bob 1 +
result:
ok The player wins!
Test #5:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
3 1 1 0 1 1 * 1
output:
Bob 1 *
result:
ok The player wins!
Test #6:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
3 0 1 0 1 1 * 1
output:
Bob 1 +
result:
ok The player wins!
Test #7:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
2 1 0 1 1
output:
Alice 1 +
result:
ok The player wins!
Test #8:
score: 0
Accepted
time: 0ms
memory: 3796kb
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 + 4 + 6 + 10 + 12 + 12 + 14 + 14 + 16 + 20 + 20 + 20 + 20 + 22 + 22 + 24 + 24 + 26 + 26 + 26 + 28 + 28 + 28 + 28 + 30 + 30 + 30 + 32 + 32 + 34 + 36 + 38 + 40 + 40 + 48 + 48 + 48 + 48 + 48 + 52 + 54 + 54 + 54 + 58 + 58 + 58 + 60 + 60 + 62 + 66 + 68 + 70 + 70 + 72 + 74 + 76 + 76 + 78 +...
result:
ok The player wins!
Test #9:
score: -100
Wrong Answer
time: 0ms
memory: 3772kb
input:
499 0 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 0 1 1 1 1 1 0 1 0 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 0 1 1 1 0 1 0 1 0 1 1 1 0 1 1 1 0 1 1 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 0 1 ...
output:
Alice 1 + 3 + 3 + 3 + 5 + 7 + 7 + 9 + 11 + 13 + 13 + 15 + 15 + 19 + 19 + 19 + 19 + 19 + 21 + 23 + 25 + 25 + 25 + 27 + 27 + 31 + 33 + 35 + 35 + 35 + 35 + 37 + 39 + 45 + 47 + 49 + 49 + 51 + 51 + 53 + 53 + 55 + 59 + 61 + 61 + 63 + 65 + 65 + 67 + 67 + 71 + 71 + 73 + 75 + 77 + 77 + 79 + 79 + 85 + 87 + 87...
result:
wrong answer The interactor wins!