-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy path2850.txt
More file actions
61 lines (55 loc) · 741 Bytes
/
2850.txt
File metadata and controls
61 lines (55 loc) · 741 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include<iostream>
using namespace std;
int main()
{
int a[15][15];
int i,j,k;
for(int m,n;cin>>m>>n&&n!=0&&m!=0;)
{
for(j=1;j<=m;j++)
for(k=1;k<=n;k++)
cin>>a[j][k];
bool it=true;
for(j=1;j<=m;j++)
for(k=1;k<=n;k++)
{
if(a[j][k]==0)
{
if(j-1>0)
{
if(a[j-1][k]==0)
it=false;
}
if(j+1<=m)
{
if(a[j+1][k]==0)
it=false;
}
if(k-1>0)
{
if(a[j][k-1]==0)
it=false;
}
if(k+1<=n)
{
if(a[j][k+1]==0)
it=false;
}
}
}
int sum=0;
for(j=1;j<=m;j++)
for(k=1;k<=n;k++)
{
if(a[j][k]==1)
sum++;
}
if(sum==m*n)
it=false;
if(it==true)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return 0;
}