UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#195513#3419. 方格判定heyuzhen100284ms2388kbC++11730b2023-10-18 19:10:142023-10-18 22:17:44

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define A for(ll i=1;i<=n;i++)for(ll j=1;j<=m;j++)
ll n,m,a,b;string s[2005];bitset<1005> ok[1005];
bool check(ll x,ll y){
	if(x<5||y<5||x+5>n||y+5>m)return 0;
	for(ll i=x-4;i<=x+5;i++)for(ll j=y-4;j<=y+5;j++){
		if(i<x-1||j<y-1||i>x+2||j>y+2||
			(i==x-1&&(j==y-1||j==y+2))||(i==x+2&&(j==y-1||j==y+2))){
			if(s[i][j]=='.')return 0;
		}else if(s[i][j]=='#')return 0;}
	return 1;
}
int main(){
	cin>>n>>m;for(ll i=1;i<=n;i++){cin>>s[i];s[i]=" "+s[i];}
	A ok[i][j]=check(i,j);
	A if(ok[i][j]){if(ok[i+7][j]){ok[i+7][j]=ok[i][j]=0;a++;}
		else if(ok[i][j+7]){ok[i][j+7]=ok[i][j]=0;a++;}
		else b++,ok[i][j]=0;
	}cout<<a<<" "<<b;
	return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 1ms
memory: 1392kb

input:

17 17
......##########.
......##########.
......##########.
......####..####.
......###....###.
.......

output:

1 0

result:

ok single line: '1 0'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1392kb

input:

17 17
...........###...
...........###...
...........###...
...........###...
....##########...
.......

output:

0 1

result:

ok single line: '0 1'

Test #3:

score: 10
Accepted
time: 0ms
memory: 1392kb

input:

17 17
.................
.................
.................
.................
.##############..
.###...

output:

0 1

result:

ok single line: '0 1'

Test #4:

score: 10
Accepted
time: 0ms
memory: 1396kb

input:

50 50
##########...................##############....###
##########...................##############...

output:

1 11

result:

ok single line: '1 11'

Test #5:

score: 10
Accepted
time: 0ms
memory: 1396kb

input:

50 50
......................###.........................
......................###.....................

output:

5 5

result:

ok single line: '5 5'

Test #6:

score: 10
Accepted
time: 0ms
memory: 1392kb

input:

50 50
......##########..................................
......##########.......####################...

output:

7 2

result:

ok single line: '7 2'

Test #7:

score: 10
Accepted
time: 79ms
memory: 2388kb

input:

1000 1000
##########..##########..##########..##########..##########..##########..##########..######...

output:

4316 0

result:

ok single line: '4316 0'

Test #8:

score: 10
Accepted
time: 75ms
memory: 2388kb

input:

1000 1000
.............................................................................................

output:

539 235

result:

ok single line: '539 235'

Test #9:

score: 10
Accepted
time: 62ms
memory: 2388kb

input:

1000 1000
.............................................................................................

output:

3 7

result:

ok single line: '3 7'

Test #10:

score: 10
Accepted
time: 67ms
memory: 2388kb

input:

1000 1000
.............................................................................................

output:

9 1

result:

ok single line: '9 1'

Extra Test:

score: 0
Extra Test Passed