Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <assert.h>
- #include <bits/stdc++.h>
- using namespace std;
- bool is_square(const vector<vector<int>> &g, int r, int c, int len)
- {
- if (r - len < 0 || c - len < 0)
- return false;
- for (int i = r; i >= r - len; --i)
- if (g[i][c] == 0 || g[i][c - len] == 0)
- return false;
- for (int i = c; i >= c - len; --i)
- if (g[r][i] == 0 || g[r - len][i] == 0)
- return false;
- return true;
- }
- int main(int argc, char **argv)
- {
- int n, m;
- cin >> n >> m;
- vector<vector<int>> g(n, vector<int>(m));
- for (int i = 0; i < n; ++i)
- for (int j = 0; j < m; ++j)
- cin >> g[i][j];
- int ans_r, ans_c, ans_w = 0;
- for (int i = 0; i < n; ++i)
- for (int j = 0; j < m; ++j) {
- int max_d = min(i, j);
- while (max_d >= ans_w) {
- if (is_square(g, i, j, max_d))
- ans_w = max_d + 1, ans_r = i, ans_c = j;
- max_d--;
- }
- }
- cout << ans_r << ' ' << ans_c << ' ' << ans_w << endl;
- return 0;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement