Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- short n, m, a[1002][1002];
- int main(){
- ifstream cin("hambar.in");
- ofstream cout("hambar.out");
- cin >> n >> m;
- vector<vector<bool> > v(n + 1, vector<bool>(n + 1, 1));
- while(m--){
- short x, y;
- cin >> x >> y;
- v[x][y] = 0;
- }
- for(short j = 1; j <= n; ++j){
- for(short i = 1; i <= n; ++i)
- a[i][j] = a[i - 1][j] + v[i][j];
- }
- short ans = 0, s = 0, set = 0;
- for(short r1 = 1; r1 <= n; ++r1){
- for(short r2 = r1; r2 <= n; ++r2){
- s = 0, set = r2 - r1 + 1;
- for(short j = 1; j <= n; ++j){
- if(a[r2][j] - a[r1 - 1][j] == set)
- s += set;
- else
- s = 0;
- ans = max(ans, s);
- }
- }
- }
- cout << ans << '\n';
- cin.close(), cout.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement