ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#195518 | #3419. 方格判定 | ChiefJustice | 100 | 237ms | 3152kb | C++11 | 1.8kb | 2023-10-18 19:10:43 | 2023-10-18 22:18:01 |
answer
#include<bits/stdc++.h>
#define fi first
#define se second
#define db double
#define U unsigned
#define P pair<int,int>
#define int long long
#define pb push_back
#define MP make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define gc getchar()
#define pc putchar
using namespace std;
inline int rd(){
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
return x*f;
}
inline void wr(int x){
if(x<0) x=-x;
if(x>9) wr(x/10);
pc((x%10)^48);
}
char a[1005][1005];
bool fl[1005][1005];
int n,m;
bool slove(int x,int y){
if(x<1||x>n||y<1||y>m||fl[x][y]) return 0;
if(a[x][y]=='.' &&a[x][y+1]=='.'&&a[x+3][y]=='.'&&a[x+3][y+1]=='.'){
FOR(i,x+1,x+2){
FOR(j,y-1,y+2){
if(a[i][j]=='#') return 0;
}
}
if(a[x-1][y]=='.'||a[x-1][y+1]=='.'||a[x][y+2]=='.'||a[x][y-1]=='.'||a[x+1][y-2]=='.'||a[x+1][y+3]=='.'||a[x+2][y-2]=='.'||a[x+2][y+3]=='.'||a[x+3][y-1]=='.'||a[x+3][y+2]=='.'||a[x+4][y]=='.'||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(i,x+1,x+2){
FOR(j,y-1,y+2){
fl[i][j]=1;
}
}
return 1;
}
return 0;
}
int type_c,type_s;
signed main(){
cin>>n>>m;
FOR(i,1,n){
FOR(j,1,m) cin>>a[i][j];
}
FOR(i,1,n){
FOR(j,1,m){
if(a[i][j]=='.'){
if(slove(i,j)){
if(slove(i-7,j)||slove(i,j+7)||slove(i+7,j)||slove(i,j-7)) type_c++;
else type_s++;
}
}
}
}
cout<<type_c<<' '<<type_s;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1220kb
input:
17 17 ......##########. ......##########. ......##########. ......####..####. ......###....###. .......
output:
1 0
result:
ok single line: '1 0'
Test #2:
score: 10
Accepted
time: 0ms
memory: 1216kb
input:
17 17 ...........###... ...........###... ...........###... ...........###... ....##########... .......
output:
0 1
result:
ok single line: '0 1'
Test #3:
score: 10
Accepted
time: 0ms
memory: 1216kb
input:
17 17 ................. ................. ................. ................. .##############.. .###...
output:
0 1
result:
ok single line: '0 1'
Test #4:
score: 10
Accepted
time: 0ms
memory: 1276kb
input:
50 50 ##########...................##############....### ##########...................##############...
output:
1 11
result:
ok single line: '1 11'
Test #5:
score: 10
Accepted
time: 1ms
memory: 1288kb
input:
50 50 ......................###......................... ......................###.....................
output:
5 5
result:
ok single line: '5 5'
Test #6:
score: 10
Accepted
time: 0ms
memory: 1288kb
input:
50 50 ......##########.................................. ......##########.......####################...
output:
7 2
result:
ok single line: '7 2'
Test #7:
score: 10
Accepted
time: 53ms
memory: 2948kb
input:
1000 1000 ##########..##########..##########..##########..##########..##########..##########..######...
output:
4316 0
result:
ok single line: '4316 0'
Test #8:
score: 10
Accepted
time: 62ms
memory: 3152kb
input:
1000 1000 .............................................................................................
output:
539 235
result:
ok single line: '539 235'
Test #9:
score: 10
Accepted
time: 57ms
memory: 2248kb
input:
1000 1000 .............................................................................................
output:
3 7
result:
ok single line: '3 7'
Test #10:
score: 10
Accepted
time: 64ms
memory: 2284kb
input:
1000 1000 .............................................................................................
output:
9 1
result:
ok single line: '9 1'
Extra Test:
score: 0
Extra Test Passed