QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#371402 | #8507. Clever Cell Choices | Mo_Han136# | WA | 1ms | 3924kb | C++20 | 1.4kb | 2024-03-30 10:41:02 | 2024-03-30 10:41:04 |
Judging History
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'