chuoingoacsol
quoc14
c_cpp
a year ago
1.1 kB
17
Indexable
caidat
// Online C++ compiler to run C++ program online
#include <iostream>
using namespace std;
char a[105][105];
int ans;
int tmp, x, y;
void lan(int i, int j) {
// lan ngang
tmp = 1;
x = j -1;
y = j + 1;
while (x >= 1 && y <= 100) {
if (a[i][x] == a[i][y]) {
tmp += 2;
}
else {
if (tmp > ans) ans = tmp;
break;
}
}
// lan doc
tmp = 1;
x = i -1;
y = i + 1;
while (x >= 1 && y <= 100) {
if (a[x][j] == a[y][j]) {
tmp += 2;
}
else {
if (tmp > ans) ans = tmp;
break;
}
}
}
void solve(int testcase) {
for (int i = 1; i <= 100; i++) {
for (int j = 1; j <= 100; j++) {
cin >> a[i][j];
}
}
ans = 0;
for (int i = 1; i <= 100; i++) {
for (int j = 1; j <= 100; j++) {
lan(i, j);
}
}
cout << "#" << testcase << " " << ans << endl;
}
int main() {
// Write C++ code here
int n; cin >> n;
solve(n);
return 0;
}Editor is loading...
Leave a Comment