# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
949763 | 2024-03-19T16:19:36 Z | ALTAKEXE | Soccer Stadium (IOI23_soccer) | C++17 | 0 ms | 0 KB |
#include <bits/stdc++.h> using namespace std; bool is_regular(int N, int r, int c, int s, const vector<vector<int>>& F) { vector<vector<int>> trees(F); for (int i = r; i < r + s; i++) { for (int j = c; j < c + s; j++) { if (trees[i][j] == 1) { return false; } } } for (int i = r; i < r + s; i++) { int count = count_if(trees[i].begin() + c, trees[i].begin() + c + s, [](int val){ return val == 0; }); if (count != s && count != 0) { return false; } } for (int j = c; j < c + s; j++) { int count = 0; for (int i = r; i < r + s; i++) { if (trees[i][j] == 0) { count++; } } if (count != s && count != 0) { return false; } } return true; } int biggest_stadium(int N, const vector<vector<int>>& F) { int max_size = 1; for (int r = 0; r < N; r++) { for (int c = 0; c < N; c++) { for (int s = 1; s <= N; s++) { if (r + s <= N && c + s <= N && is_regular(N, r, c, s, F)) { max_size = max(max_size, s); } } } } return max_size * max_size; }