QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#572412#5077. Card Gamedaxinghao#WA 7ms30312kbC++141.9kb2024-09-18 14:22:352024-09-18 14:22:35

Judging History

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

  • [2024-09-18 14:22:35]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:30312kb
  • [2024-09-18 14:22:35]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n, m, i, j, k, a, b, dp[51][51][51][51], X;
char S[26][26];
int dfs(int x1, int y1, int x2, int y2)
{
    if(x1>x2||y1>y2)return 0;
    if(dp[x1][y1][x2][y2]!=-1)return dp[x1][y1][x2][y2];
    vector<int>v;
    for(int i=x1;i<=x2;i+=2)
    {
        for(int j=y1;j<=y2;j+=2)
        {
            a=(i-j+n-1)/2, b=(i+j-n+1)/2;
            if(0<=a&&a<n&&0<=b&&b<m)
            {
                if(S[a][b]=='R')
                {
                    v.push_back(dfs(x1, y1, i-2, y2)^dfs(i+2, y1, x2, y2));
                }
                else if(S[a][b]=='B')
                {
                    v.push_back(dfs(x1, y1, x2, j-2)^dfs(x1, j+2, x2, y2));
                }
                else
                {
                    v.push_back(dfs(x1, y1, i-2, j-2)^dfs(x1, j+2, i-2, y2)^dfs(i+2, y1, x2, j-2)^dfs(i+2, j+2, x2, y2));
                }
            }
        }
    }
    //printf("%d %d %d %d\n", x1, y1, x2, y2);
    //for(auto p:v)cout<<p<<" ";puts("");
    if(v.size()==0)return dp[x1][y1][x2][y2]=0;
    sort(v.begin(), v.end());
    if(v[0]!=0)return dp[x1][y1][x2][y2]=0;
    int i=1;
    for(;i<v.size();i++)if(v[i]>v[i-1]+1)break;
    if(i<v.size())return dp[x1][y1][x2][y2]=v[i]-1;
    else return dp[x1][y1][x2][y2]=v.back()+1;
}
main()
{
    scanf("%d %d", &n, &m);
    for(i=0;i<n;i++)scanf("%s", &S[i]);
    for(i=0;i<=50;i++)for(j=0;j<=50;j++)for(k=0;k<=50;k++)for(int l=0;l<=50;l++)dp[i][j][k][l]=-1;
    if((n-1)%2==0)
    {
        if((n+m-2)%2==0)
        X=dfs(0, 0, n+m-2, n+m-2)^dfs(1, 1, n+m-3, n+m-3);
        else
        X=dfs(0, 0, n+m-3, n+m-3)^dfs(1, 1, n+m-2, n+m-2);
    }
    else
    {
        if((n+m-2)%2==0)
        X=dfs(0, 1, n+m-2, n+m-3)^dfs(1, 0, n+m-3, n+m-2);
        else
        X=dfs(0, 1, n+m-3, n+m-2)^dfs(1, 0, n+m-2, n+m-3);
    }
    if(X)puts("W");else puts("L");
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 30096kb

input:

1 3
BBB


output:

W

result:

ok single line: 'W'

Test #2:

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

input:

2 3
BBG
RGR


output:

W

result:

ok single line: 'W'

Test #3:

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

input:

2 2
GG
GG


output:

L

result:

ok single line: 'L'

Test #4:

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

input:

1 10
RRRRRRRRRR

output:

L

result:

ok single line: 'L'

Test #5:

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

input:

1 11
BBBBBBBBBBB

output:

W

result:

ok single line: 'W'

Test #6:

score: 0
Accepted
time: 7ms
memory: 30088kb

input:

10 1
G
G
G
G
G
G
G
G
G
G

output:

L

result:

ok single line: 'L'

Test #7:

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

input:

11 1
R
R
R
R
R
R
R
R
R
R
R

output:

W

result:

ok single line: 'W'

Test #8:

score: -100
Wrong Answer
time: 0ms
memory: 30040kb

input:

2 20
BBGGBGBGGBBGGBGGBGGG
GGBBBGBGBBBGBGGGGGGG

output:

W

result:

wrong answer 1st lines differ - expected: 'L', found: 'W'