Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int maxn = 1010;
- int pref[maxn][maxn];
- int p[maxn][maxn];
- int n;
- void build() {
- for (int i = 0; i < n; ++i) {
- for (int j = 0; j < n; ++j) {
- pref[i + 1][j + 1] = p[i][j] + pref[i][j + 1] + pref[i + 1][j] - pref[i][j];
- }
- }
- }
- int get(int x1, int y1, int x2, int y2) {
- return pref[x2 - 1][y2 - 1] - pref[x1][y2 - 1] - pref[x2 - 1][y1] + pref[x1][y1];
- }
- bool check_rect(int a, int b) {
- for (int i = 0; i < n; ++i) {
- for (int j = 0; j < n; ++j) {
- if (i + a > n || j + b > n)
- continue;
- if (get(i, j, i + a, j + b) == 0)
- return true;
- }
- }
- return false;
- }
- bool check(int s) {
- for (int i = 1; i * i <= s; ++i) {
- if (s % i == 0 && check_rect(i, s / i))
- return true;
- }
- return false;
- }
- void solve() {
- cin >> n >> n;
- int k;
- cin >> k;
- for (int i = 0; i < k; ++i) {
- int x, y;
- cin >> x >> y;
- x--, y--;
- p[x][y] = 1;
- }
- build();
- cout << check(7) << '\n';
- int l = 0;
- int r = 1e6;
- while (r - l > 1) {
- int m = (r + l) / 2;
- if (check(m)) {
- l = m;
- } else {
- r = m;
- }
- }
- cout << l << '\n';
- }
- signed main() {
- ios::sync_with_stdio(0); cin.tie(0);
- solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement