-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEmaSupercomputer.cpp
More file actions
100 lines (84 loc) · 2.21 KB
/
EmaSupercomputer.cpp
File metadata and controls
100 lines (84 loc) · 2.21 KB
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
100
// problem: "https://www.hackerrank.com/challenges/two-pluses/problem"
#include<iostream>
#include<vector>
using namespace std;
int checkMax(vector<vector<char>>G,int n,int m)
{
int l = 0;
int i,j;
for(i=0;i!=n;i++)
{
for(j=0;j!=m;j++)
{
if(G[i][j]=='G')
{
int k=0;
while(1)
{
if(i-k>=0 && i+k<n && j-k>=0 && j+k<m)
{
if(G[i-k][j] == 'G' && G[i+k][j] == 'G' &&
G[i][j-k] == 'G' && G[i][j+k] == 'G')
k++;
else
break;
}
else
break;
}
l = max(l,k);
}
}
}
return 4*l-3;
}
int MaxArea(vector<vector<char>>&G,int n,int m)
{
vector<vector<char>>Gcopy(G);
int i,j;
int a,b,A;
A = 0;
for(i=0;i!=n;i++)
{
for(j=0;j!=m;j++)
{
vector<vector<char>> Gcopy(G);
if(Gcopy[i][j]=='G')
{
int k=0;
while(1)
{
if(i-k>=0 && i+k<n && j-k>=0 && j+k<m)
{
if (Gcopy[i-k][j] == 'G' && Gcopy[i+k][j] == 'G' &&
Gcopy[i][j-k] == 'G' && Gcopy[i][j+k] == 'G')
{
Gcopy[i-k][j] = Gcopy[i+k][j] = Gcopy[i][j-k] = Gcopy[i][j+k] = 'B';
a = 4*(k+1)-3;
b = checkMax(Gcopy,n,m); // define function
A = max(A,a*b);
}
else
break;
}
else
break;
k++;
}
}
}
}
return A;
}
int main()
{
int n, m;
cin >> n >> m;
vector<vector<char>> G(n, vector<char>(m));
int i, j;
for (i = 0; i != n; i++)
for (j = 0; j != m; j++)
cin >> G[i][j];
cout << MaxArea(G, n, m); // define func
return 0;
}