Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- constexpr int maxn = 1010;
- int v[maxn][maxn], h[maxn] = {}, st[maxn], dr[maxn], stiva[maxn] = {}, poz = -1,
- n, m;
- ifstream f("hambar.in");
- ofstream g("hambar.out");
- void do_st_dr(){
- stiva[poz=0] = -1;
- for(int i = 0; i < n; ++i){
- while(stiva[poz] != -1 && h[stiva[poz]] >= h[i]) --poz;
- st[i] = stiva[poz]+1;
- stiva[++poz] = i; }
- stiva[poz=0] = n;
- for(int i = n-1; i >= 0; --i){
- while(stiva[poz] != n && h[stiva[poz]] >= h[i]) --poz;
- dr[i] = stiva[poz]-1;
- stiva[++poz] = i; } }
- int main(){
- f >> n >> m;
- for(int i = 0, x, y; i < m; ++i)
- f >> x >> y,
- v[x-1][y-1] = 1;
- int rez = 0;
- for(int i = 0; i < n; ++i){
- for(int j = 0; j < n; ++j)
- if(!v[i][j]) ++h[j];
- else h[j] = 0;
- do_st_dr();
- for(int j = 0; j < n; ++j) cout << h[j] << ' ';
- cout << endl;
- /**
- for(int j = 0; j < n; ++j) cout << dr[j] << ' ';
- cout << endl;
- cout << endl;
- /**
- for(int j = 0; j < n; ++j) cout << dr[j] << ' ';
- cout << endl;
- cout << endl;
- **/
- for(int j = 0; j < n; ++j)
- rez = max(rez, h[j] * (dr[j] - st[j] + 1));
- }
- g << rez << endl;
- return 0; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement