forked from aviraw/CodeChef
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchainrxn
47 lines (46 loc) · 973 Bytes
/
chainrxn
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
#include<iostream>
using namespace std;
int main()
{
int t=0,r,c;
cin>>t;
int res[t]={0};
for(int i=0;i<t;i++)
{
cin>>r>>c;
int ar[r][c];
for(int j=0;j<r;j++)
{
for(int k=0;k<c;k++)
{
cin>>ar[j][k];
}
}
for(int j=0;j<r;j++)
{
for(int k=0;k<c;k++)
{
if((ar[0][0]<2&&ar[r-1][c-1]<2&&ar[0][c-1]<2&&ar[r-1][0]<2)
&&(ar[j][0]<3&&ar[0][k]<3&&ar[j][c-1]<3&&ar[r-1][k]<3)
&&(ar[j][k]<4))
{
res[i]=1;
break;
}
else
{
res[i]=0;
break;
}
}
}
}
for(int i=0;i<t;i++)
{
if(res[i]==1)
cout<<"Stable"<<endl;
else
cout<<"Unstable"<<endl;
}
return 0;
}