QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#341848#7863. Parity GamegoodierWA 1ms3880kbC++173.7kb2024-02-29 21:56:072024-02-29 21:56:08

Judging History

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

  • [2024-02-29 21:56:08]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3880kb
  • [2024-02-29 21:56:07]
  • 提交

answer

#include <bits/stdc++.h>

#define ffl fflush(stdout)

using namespace std;
const int N = 550;
int a[N], n, t;

void Del(int x, int n)
{
    for(int i = x; i < n; i++)
    {
        a[i] = a[i + 1];
    }
}

int main()
{
    scanf("%d%d", &n, &t);
    int len = 0, res0 = 0, res1 = 0;
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        if(a[i])
        {
            len++;
        }
        else
        {
            res1 += (len + 1) / 2; len = 0;
            res0++;
        }
    }
    res1 += (len + 1) / 2; len = 0;
    int flag0 = 0;
    if(!t)
    {
        if(res1 <= res0) flag0 = 1;
    }
    else
    {
        if(res1 < res0) flag0 = 1;
    }
    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 + 1, 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 + 1, len);
                            a[i] = 0;
                            break;
                        }
                    }
                }
            }
            else
            {
                char str[2]; int x;
                scanf("%s%d", str, &x);
                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)
            {
                for(int i = 1; i < len; i++)
                {
                    if(a[i] == 0)
                    {
                        if(a[i + 1] == 1)
                        {
                            printf("+ %d\n", i);
                            a[i] = 1;
                        }
                        else
                        {
                            printf("* %d\n", i);
                        }
                        ffl;
                        Del(i + 1, len);
                        break;
                    }
                }
            }
            else
            {
                char str[2]; int x;
                scanf("%s%d", str, &x);
                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);
            }
        }
        if(a[1] + a[2] == 1)
        {
            puts("+ 1");
            ffl;
        }
        else
        {
            puts("* 1");
            ffl;
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3880kb

input:

4 1
0 1 0 1

output:

Alice
+ 1

result:

wrong answer format  Expected integer, but "+" found