-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathADAPLUS.cpp
99 lines (87 loc) · 2.13 KB
/
ADAPLUS.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int min4(int m1,int m2,int m3,int m4)
{
return min(min(m1,m2) , min(m3,m4));
}
int main()
{
int t,n,count,temp;
cin>>t;
char c;
while(t--)
{
cin>>n;
int a[n][n];
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
cin>>c;
if(c=='.')
a[i][j] = 0;
else
a[i][j] = 1;
}
}
int preX[n][n] , postX[n][n];
int preY[n][n] , postY[n][n];
for(int i=0;i<n;i++)
{
count = 0;
for(int j=0;j<n;j++)
{
preX[i][j] = count;
if(a[i][j] == 0)
count=0;
else
count++;
}
count = 0;
for(int j=n-1 ; j>=0;j--)
{
postX[i][j] = count;
if(a[i][j] == 0)
count = 0;
else
count++;
}
count = 0;
for(int j=0;j<n;j++)
{
preY[j][i] = count;
if(a[j][i] == 0)
count=0;
else
count++;
}
count = 0;
for(int j=n-1 ; j>=0;j--)
{
postY[j][i] = count;
if(a[j][i] == 0)
count = 0;
else
count++;
}
}
count = 0;
for (int i = 0; i < n; ++i)
{
for (int j = 0; j < n; ++j)
{
//cout<<i<<" "<<j<<" : "<<preX[i][j]<<" "<<postX[i][j]<<" "<<preY[i][j]<<" "<<postY[i][j]<<endl;
if(a[i][j]==1)
{
temp = min4(preX[i][j] , postX[i][j], preY[i][j], postY[i][j]) + 1;
if(temp>count)
count = temp;
}
}
}
cout<<count<<endl;
}
return 0;
}