Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #1972
- #include <fstream>
- using namespace std;
- ifstream fin("hambar.in");
- ofstream fout("hambar.out");
- int a[1002][2];
- int n,m,k=1,i;
- int smax=0;
- int cauta(int l1, int c1, int l2, int c2, int k)
- {
- while(k<=m)
- if(a[k][0]>=l1 and a[k][0]<=l2 and a[k][1]>=c1 and a[k][1]<=c2)
- return k;
- else
- k++;
- return 0;
- }
- void div(int l1, int c1, int l2, int c2, int p)
- {
- int sa=(l2-l1+1)*(c2-c1+1);
- if(smax<sa)
- {
- p=cauta( l1, c1, l2, c2, p);
- if(p==0)
- smax=max(smax, sa);
- else
- {
- div(l1, c1, l2, a[p][1]-1,p+1);
- div(l1, a[p][1]+1, l2, c2,p+1);
- div(l1, c1, a[p][0]-1, c2,p+1);
- div(a[p][0]+1, c1, l2, c2,p+1);
- }
- }
- }
- int main()
- {
- fin>>n>>m;
- for(i=1; i<=m; i++)
- fin>>a[i][0]>>a[i][1];
- div(1,1,n,n,1);
- fout<<smax;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement