QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#371402#8507. Clever Cell ChoicesMo_Han136#WA 1ms3924kbC++201.4kb2024-03-30 10:41:022024-03-30 10:41:04

Judging History

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

  • [2024-03-30 10:41:04]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3924kb
  • [2024-03-30 10:41:02]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N=55;
char s[N][N];bool bk[N][N];int Sum1,Sum2,n,m;
void dfs(int x,int y,int c){
    bk[x][y]=false;
    if(!c) Sum1++;else Sum2++;
    if(x>1&&bk[x-1][y]&&s[x-1][y]=='.') dfs(x-1,y,c^1);
    if(y>1&&bk[x][y-1]&&s[x][y-1]=='.') dfs(x,y-1,c^1);
    if(x<n&&bk[x+1][y]&&s[x+1][y]=='.') dfs(x+1,y,c^1);
    if(x<m&&bk[x][y+1]&&s[x][y+1]=='.') dfs(x,y+1,c^1);
}

int main()
{

    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%s",s[i]+1);

    memset(bk,true,sizeof(bk));
    int mx=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            if(bk[i][j]&&s[i][j]=='.'){
                Sum1=Sum2=0;
                dfs(i,j,0);
                mx+=min(Sum1,Sum2);
            }

    int Ans=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            if(s[i][j]=='.'){
                s[i][j]='#';
                memset(bk,true,sizeof(bk));
                int Sum=0;
                for(int k=1;k<=n;k++)
                    for(int l=1;l<=m;l++)
                        if(bk[k][l]&&s[k][l]=='.'){
                            Sum1=Sum2=0;
                            dfs(k,l,0);
                            Sum+=min(Sum1,Sum2);
                        }
                if(Sum==mx) Ans++;
                s[i][j]='.';
            }
    printf("%d\n",Ans);
    return 0;
}

詳細信息

Test #1:

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

input:

3 3
#.#
...
#.#

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

3 3
..#
...
...

output:

0

result:

ok 1 number(s): "0"

Test #3:

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

input:

1 4
...#

output:

2

result:

ok 1 number(s): "2"

Test #4:

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

input:

1 5
####.

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

1 6
#..###

output:

0

result:

ok 1 number(s): "0"

Test #6:

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

input:

2 5
....#
###.#

output:

3

result:

ok 1 number(s): "3"

Test #7:

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

input:

2 6
...##.
.#.###

output:

4

result:

ok 1 number(s): "4"

Test #8:

score: -100
Wrong Answer
time: 1ms
memory: 3784kb

input:

5 5
##...
##.#.
##.##
##.#.
.##..

output:

6

result:

wrong answer 1st numbers differ - expected: '7', found: '6'