Advertisement
rotti321

Untitled

Mar 21st, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. /*
  2.     Prof. Daniel Popa, Colegiul National Aurel Vlaicu Orastie
  3.     Divide et Impera
  4. */
  5. #include <iostream>
  6. #include <fstream>
  7. #define si short int
  8. #define ar(l1, c1, l2, c2) (l2-l1+1)*(c2-c1+1)
  9. using namespace std;
  10. typedef struct pom{si l,c;};
  11. pom a[1002];
  12. si n,m,k=1,i;
  13. int smax=0;
  14. si cauta(si l1, si c1, si l2, si c2, si k)
  15. {
  16.     while(k<=m)
  17.         if(a[k].l>=l1 and a[k].l<=l2 and a[k].c>=c1 and a[k].c<=c2) return k;
  18.             else k++;
  19.     return 0;
  20. }
  21.  
  22. void arie(si l1, si c1, si l2, si c2)
  23. {
  24.     int s=(l2-l1+1)*(c2-c1+1);
  25.      smax=max(s,smax);
  26. }
  27. int z;
  28. void div(si l1, si c1, si l2, si c2, si p)
  29. {
  30.     int sa=ar(l1,c1,l2,c2);
  31.    if(smax<sa)
  32.    {
  33.         p=cauta( l1, c1, l2, c2, p);
  34.        if(p==0)smax=max(smax, sa);
  35.          else
  36.          {
  37.              div(l1, c1, l2, a[p].c-1,p+1);
  38.              div(l1, a[p].c+1, l2, c2,p+1);
  39.              div(l1, c1, a[p].l-1, c2,p+1);
  40.              div(a[p].l+1, c1, l2, c2,p+1);
  41.          }
  42.    }
  43. }
  44. int main()
  45. {
  46.     ifstream fin("hambar.in");
  47.     ofstream fout("hambar.out");
  48.     fin>>n>>m;
  49.     for(i=1;i<=m;i++)fin>>a[i].l>>a[i].c;
  50.     div(1,1,n,n,1);
  51.     fout<<smax;
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement