UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#195239#3419. 方格判定caoanzheng10080ms3208kbC++1.5kb2023-10-18 18:41:352023-10-18 21:59:29

answer

#include<bits/stdc++.h>
#define int long long
#define DEBUG(x) cerr<<#x<<'='<<x<<endl
using namespace std;
char mp[1005][1005];
bool vis[1005][1005];
int n,m;
bool judge(int x,int y)
{
	if(x<1||x>n||y<1||y>m||vis[x][y])
	{
		return 0;
	}
	if(mp[x][y]=='.'&&mp[x][y+1]=='.'&&mp[x+3][y]=='.'&&mp[x+3][y+1]=='.')
	{
		for(int i=x+1;i<=x+2;i++)
		{
			for(int j=y-1;j<=y+2;j++)
			{
				if(mp[i][j]=='#')
				{
					return 0;
				}
			}
		}
		if(mp[x-1][y]=='.'||mp[x-1][y+1]=='.'||mp[x][y+2]=='.'||mp[x][y-1]=='.'||mp[x+1][y-2]=='.'||mp[x+1][y+3]=='.'||mp[x+2][y-2]=='.'||mp[x+2][y+3]=='.'||mp[x+3][y-1]=='.'||mp[x+3][y+2]=='.'||mp[x+4][y]=='.'||mp[x+4][y+1]=='.')
		{
			return 0;
		}
		vis[x][y]=1,vis[x][y+1]=1,vis[x+3][y]=1,vis[x+3][y+1]=1;
		for(int i=x+1;i<=x+2;i++)
		{
			for(int j=y-1;j<=y+2;j++)
			{
				vis[i][j]=1;
			}
		}
		return 1;
	}
	return 0;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=m;j++)
    	{
    		cin>>mp[i][j];
		}
	}
	int fir=0,sec=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(mp[i][j]=='.')
			{
				if(judge(i,j))
				{
					if(judge(i-7,j)||judge(i,j+7)||judge(i+7,j)||judge(i,j-7))
					{
						fir++;
					}
					else
					{
						sec++;
					}
				}
			}
		}
	}
	cout<<fir<<' '<<sec;
    //fclose(stdin);
    //fclose(stdout);
	return 0;
}

详细

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

Test #1:

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

input:

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

output:

1 0

result:

ok single line: '1 0'

Test #2:

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

input:

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

output:

0 1

result:

ok single line: '0 1'

Test #3:

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

input:

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

output:

0 1

result:

ok single line: '0 1'

Test #4:

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

input:

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

output:

1 11

result:

ok single line: '1 11'

Test #5:

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

input:

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

output:

5 5

result:

ok single line: '5 5'

Test #6:

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

input:

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

output:

7 2

result:

ok single line: '7 2'

Test #7:

score: 10
Accepted
time: 13ms
memory: 3004kb

input:

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

output:

4316 0

result:

ok single line: '4316 0'

Test #8:

score: 10
Accepted
time: 19ms
memory: 3208kb

input:

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

output:

539 235

result:

ok single line: '539 235'

Test #9:

score: 10
Accepted
time: 18ms
memory: 2304kb

input:

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

output:

3 7

result:

ok single line: '3 7'

Test #10:

score: 10
Accepted
time: 28ms
memory: 2340kb

input:

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

output:

9 1

result:

ok single line: '9 1'

Extra Test:

score: 0
Extra Test Passed