QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#297471#7863. Parity Gameucup-team1525#WA 2ms3796kbC++202.3kb2024-01-04 15:32:342024-01-04 15:32:35

Judging History

你现在查看的是最新测评结果

  • [2024-01-04 15:32:35]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3796kb
  • [2024-01-04 15:32:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=505;
int n,t;
int a[N];
int f(int x)
{
    int p=0,len=0;
    for (int i=1;i<=x;++i)
    {
        if (a[i]==0)
        {
            p+=len%2;
            len=0;
            --p;
        }
        else
            ++len;
    }
    return p+len%2;
}
char s[10];



void mv(int x)
{
    for (int i=x;i<n;++i)
        a[i]=a[i+1];
}
void moni()
{
    int p;
    scanf("%d%s",&p,s);
    if (s[0]=='+')
        a[p]^=a[p+1];
    else
        a[p]&=a[p+1];
    mv(p+1);
}

void inc(int x)
{
    for (int i=1;i<x;++i)
        if (a[i]!=a[i+1])
        {
            cout<<i<<' '<<'+'<<endl;
            a[i]^=a[i+1];
            mv(i+1);
            return;
        }
    cout<<"1 *"<<endl;
    a[1]&=a[2];
    mv(2);
}
void dec(int x)
{
    for (int i=1;i<x;++i)
        if (a[i]&a[i+1])
        {
            cout<<i<<' '<<'+'<<endl;
            a[i]^=a[i+1];
            mv(i+1);
            return;
        }
    for (int i=1;i<x;++i)
        if (a[i]!=a[i+1])
        {
            cout<<i<<' '<<'*'<<endl;
            a[i]&=a[i+1];
            mv(i+1);
            return;
        }
    cout<<"1 *"<<endl;
    a[1]&=a[2];
    mv(2);
}
void workA(int d)
{
    cout<<"Alice"<<endl;
    for (int i=1;i<n;++i)
        if (i%2==1)
        {
            if (d)
                inc(n-i+1);
            else
                dec(n-i+1);
        }
        else
        {
            moni();
        }
}
void workB(int d)
{
    cout<<"Bob"<<endl;
    for (int i=1;i<n;++i)
        if (i%2==0)
        {
            if (d)
                inc(n-i+1);
            else
                dec(n-i+1);
        }
        else
        {
            moni();
        }
}

int main()
{
    scanf("%d%d",&n,&t);
    for (int i=1;i<=n;++i)
    {
        scanf("%d",&a[i]);
        // a[i]%=2;
    }
    int p=f(n);
    if (n%2==0)
    {
        if (t==0)
        {
            workA(0);
        }
        else
        {
            if (p>=0)
                workA(1);
            else
                workB(0);
        }
    }
    else
    {
        if (t==0)
        {
            if (p>0)
                workB(1);
            else
                workA(0);
        }
        else
            workB(0);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3628kb

input:

4 1
0 1 0 1
1 *
1

output:

Alice
1 +
1 +

result:

ok The player wins!

Test #2:

score: 0
Accepted
time: 1ms
memory: 3632kb

input:

4 0
1 0 1 0
1 +
1

output:

Alice
1 *
1 *

result:

ok The player wins!

Test #3:

score: 0
Accepted
time: 1ms
memory: 3696kb

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: 3604kb

input:

3 0
1 1 1
1 +
1

output:

Bob
1 +

result:

ok The player wins!

Test #5:

score: 0
Accepted
time: 1ms
memory: 3636kb

input:

3 1
1 0 1
1 *
1

output:

Bob
1 *

result:

ok The player wins!

Test #6:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

3 0
1 0 1
1 *
1

output:

Bob
1 +

result:

ok The player wins!

Test #7:

score: 0
Accepted
time: 1ms
memory: 3612kb

input:

2 1
0 1
1

output:

Alice
1 +

result:

ok The player wins!

Test #8:

score: 0
Accepted
time: 0ms
memory: 3740kb

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: 2ms
memory: 3796kb

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:

Bob
1 +
1 +
1 +
1 +
1 +
3 +
2 +
1 +
1 +
1 +
1 +
3 +
2 +
1 +
1 +
1 +
4 +
3 +
2 +
1 +
1 +
1 +
1 +
2 +
1 +
1 +
1 +
1 +
1 +
1 +
1 +
3 +
2 +
1 +
1 +
1 +
5 +
4 +
3 +
2 +
1 +
1 +
1 +
1 +
2 +
1 +
1 +
1 +
3 +
2 +
1 +
1 +
1 +
1 +
1 +
1 +
3 +
2 +
1 +
1 +
1 +
2 +
1 +
1 +
3 +
2 +
1 +
1 +
1 +
4 +
3 +
2 +
1 +
1 +
...

result:

wrong answer The interactor wins!