-
Notifications
You must be signed in to change notification settings - Fork 0
/
C.cpp
53 lines (52 loc) · 1.14 KB
/
C.cpp
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
// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
int main() {
long long h,w,i,j,cnt,p=0;
char ara[505][505];
cin>>h>>w;
for(i=0;i<h;i++)
{
for(j=0;j<w;j++)
cin>>ara[i][j];
}
for(i=0;i<h;i++)
{
for(j=0;j<w;j++)
{
if(ara[i][j]=='.')
{
cnt=0;
if(i>0)
{
if(ara[i-1][j]=='#')
cnt++;
}
if(i<h-1)
{
if(ara[i+1][j]=='#')
cnt++;
}
if(j>0)
{
if(ara[i][j-1]=='#')
cnt++;
}
if(j<w-1)
{
if(ara[i][j+1]=='#')
cnt++;
}
if(cnt>=2)
{
p=1;
cout<<i+1<<" "<<j+1<<"\n";
break;
}
}
}
if(p==1)
break;
}
return 0;
}