hiho week 222 register

Ended

Participants:151

Verdict:Accepted
Score:100 / 100
Submitted:2018-10-02 15:20:59

Lang:G++

Edit
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
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 505;
int n;
char mp[N][N];
bool isok(int x, int y, int sz) {
    if(x-sz < 0 || x+sz >= n || y-sz < 0 || y+sz >= n) return false;
    return  mp[x-sz][y] == '1' &&
            mp[x+sz][y] == '1' &&
            mp[x][y-sz] == '1' &&
            mp[x][y+sz] == '1';
}
int size(int x, int y) {
    int sz = 0;
    while(isok(x, y, sz)) sz++;
    return sz;
}
int main() {
    cin >> n;
    int ans = 0;
    for(int i = 0; i < n; i++) cin >> mp[i];
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            ans = max(ans, size(i,j));
        }
    }
    cout << ans-1 << endl;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX