QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#371404#8507. Clever Cell ChoicesMo_Han136#WA 1ms3896kbC++201.4kb2024-03-30 10:42:042024-03-30 10:42:04

Judging History

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

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

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(y<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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3
#.#
...
#.#

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

3 3
..#
...
...

output:

0

result:

ok 1 number(s): "0"

Test #3:

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

input:

1 4
...#

output:

2

result:

ok 1 number(s): "2"

Test #4:

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

input:

1 5
####.

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

1 6
#..###

output:

0

result:

ok 1 number(s): "0"

Test #6:

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

input:

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

output:

3

result:

ok 1 number(s): "3"

Test #7:

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

input:

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

output:

4

result:

ok 1 number(s): "4"

Test #8:

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

input:

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

output:

7

result:

ok 1 number(s): "7"

Test #9:

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

input:

6 6
...##.
#..#..
......
..#...
#...##
.#....

output:

1

result:

ok 1 number(s): "1"

Test #10:

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

input:

10 10
####.#...#
.#.###....
#....#..#.
.....#.#..
##.#..#.#.
..#..##...
.##.#####.
#######.##
.#.#.##..#
.#.###.##.

output:

28

result:

wrong answer 1st numbers differ - expected: '26', found: '28'