QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#534837#8507. Clever Cell ChoicesGodwangWA 0ms3952kbC++141.3kb2024-08-27 16:41:122024-08-27 16:41:14

Judging History

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

  • [2024-08-27 16:41:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3952kb
  • [2024-08-27 16:41:12]
  • 提交

answer

//#define DEBUG

#include<bits/stdc++.h>
#define LL long long
using namespace std;
template <typename T>void read(T&x){
	x=0;
	char c=getchar();
	for(;!isdigit(c);c=getchar());
	for(;isdigit(c);c=getchar())x=x*10+c-48;
}
void read(char&c){
	for(c=getchar();c!='.'&&c!='#';c=getchar());
}
#if defined(DEBUG)
#include<windows.h>
void pause(){
	if(GetAsyncKeyState(VK_SPACE)){
		while(GetAsyncKeyState(VK_SPACE));
		while(!GetAsyncKeyState(VK_SPACE));
		while(GetAsyncKeyState(VK_SPACE));
	}
}
#endif
const int dx[4]={0,0,1,-1};
const int dy[4]={1,-1,0,0};
int n,m;
bool vis[55][55];

void dfs(int x,int y,int&col1,int&col2){
	vis[x][y]=1;
	col1++;
	for(int i=0;i<4;i++){
		int nx=dx[i]+x;
		int ny=dy[i]+y;
		if(!vis[nx][ny])dfs(nx,ny,col2,col1);
	}
}
int main(){
	read(n);
	read(m);
	for(int i=1;i<=n;i++){
		vis[i][0]=vis[i][m+1]=1;
	}
	for(int i=1;i<=m;i++){
		vis[0][i]=vis[n+1][i]=1;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			char c;
			read(c);
			if(c=='#')vis[i][j]=1;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(!vis[i][j]){
				int tol1=0,tol2=0;
				dfs(i,j,tol1,tol2);
				if((tol1&1)!=(tol2&1))ans+=max(tol1,tol2);
//				printf(" %d %d\n",tol1,tol2);
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3
#.#
...
#.#

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

3 3
..#
...
...

output:

0

result:

ok 1 number(s): "0"

Test #3:

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

input:

1 4
...#

output:

2

result:

ok 1 number(s): "2"

Test #4:

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

input:

1 5
####.

output:

1

result:

ok 1 number(s): "1"

Test #5:

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

input:

1 6
#..###

output:

0

result:

ok 1 number(s): "0"

Test #6:

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

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: 0
Accepted
time: 0ms
memory: 3892kb

input:

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

output:

7

result:

ok 1 number(s): "7"

Test #9:

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

input:

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

output:

1

result:

ok 1 number(s): "1"

Test #10:

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

input:

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

output:

20

result:

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