ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#195364 | #3419. 方格判定 | maweichen | 100 | 72ms | 3212kb | C++11 | 1.4kb | 2023-10-18 18:55:08 | 2023-10-18 22:07:20 |
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
char a[1005][1005];
bool fl[1005][1005];
int n,m;
bool check(int x,int y)
{
if(x<1 or x>n or y<1 or y>m or fl[x][y])
{
return 0;
}
if(a[x][y]=='.' and a[x][y+1]=='.' and a[x+3][y]=='.' and a[x+3][y+1]=='.')
{
for(int i=x+1;i<=x+2;i++)
{
for(int j=y-1;j<=y+2;j++)
{
if(a[i][j]=='#')
{
return 0;
}
}
}
if(a[x-1][y]=='.' or a[x-1][y+1]=='.' or a[x][y+2]=='.' or a[x][y-1]=='.' or a[x+1][y-2]=='.' or a[x+1][y+3]=='.' or a[x+2][y-2]=='.' or a[x+2][y+3]=='.' or a[x+3][y-1]=='.' or a[x+3][y+2]=='.' or a[x+4][y]=='.' or a[x+4][y+1]=='.')
{
return 0;
}
fl[x][y]=1,fl[x][y+1]=1,fl[x+3][y]=1,fl[x+3][y+1]=1;
for(int i=x+1;i<=x+2;i++)
{
for(int j=y-1;j<=y+2;j++)
{
fl[i][j]=1;
}
}
return 1;
}
return 0;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin>>a[i][j];
}
}
int first=0,second=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
if(a[i][j]=='.')
{
if(check(i,j))
{
if(check(i-7,j) or check(i,j+7) or check(i+7,j) or check(i,j-7))
{
first++;
}
else
{
second++;
}
}
}
}
}
cout<<first<<' '<<second;
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: 0ms
memory: 1268kb
input:
17 17 ...........###... ...........###... ...........###... ...........###... ....##########... .......
output:
0 1
result:
ok single line: '0 1'
Test #3:
score: 10
Accepted
time: 0ms
memory: 1268kb
input:
17 17 ................. ................. ................. ................. .##############.. .###...
output:
0 1
result:
ok single line: '0 1'
Test #4:
score: 10
Accepted
time: 1ms
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: 0ms
memory: 1344kb
input:
50 50 ......##########.................................. ......##########.......####################...
output:
7 2
result:
ok single line: '7 2'
Test #7:
score: 10
Accepted
time: 7ms
memory: 3000kb
input:
1000 1000 ##########..##########..##########..##########..##########..##########..##########..######...
output:
4316 0
result:
ok single line: '4316 0'
Test #8:
score: 10
Accepted
time: 21ms
memory: 3212kb
input:
1000 1000 .............................................................................................
output:
539 235
result:
ok single line: '539 235'
Test #9:
score: 10
Accepted
time: 23ms
memory: 2304kb
input:
1000 1000 .............................................................................................
output:
3 7
result:
ok single line: '3 7'
Test #10:
score: 10
Accepted
time: 20ms
memory: 2340kb
input:
1000 1000 .............................................................................................
output:
9 1
result:
ok single line: '9 1'
Extra Test:
score: 0
Extra Test Passed