daily pastebin goal
2%
SHARE
TWEET

Untitled

a guest Mar 21st, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <fstream>
  2.  
  3. using namespace std;
  4.  
  5. ifstream f("hambar.in");
  6. ofstream g("hambar.out");
  7.  
  8. pair <short, short> a[1002];
  9. short n, m;
  10.  
  11. int smax;
  12.  
  13. short caut(short l1, short c1, short l2, short c2, short k) {
  14.     while(k <= m)
  15.         if(a[k].first >= l1 && a[k].first <= l2 && a[k].second <= c2 && a[k].second >= c1)
  16.             return k;
  17.         else k++;
  18.         return 0;
  19. }
  20. void div(short l1, short c1, short l2, short c2, short p) {
  21.     int sa = (l2-l1+1)*(c2-c1+1);
  22.     if(smax < sa) {
  23.         p = caut(l1, c1, l2, c2, p);
  24.         if(p == 0) { if(smax < sa) smax = sa; }
  25.         else {
  26.             div(l1, c1, l2, a[p].second - 1, p + 1);
  27.             div(l1, a[p].second + 1, l2, c2, p + 1);
  28.             div(l1, c1, a[p].first - 1, c2, p + 1);
  29.             div(a[p].first + 1, c1, l2, c2, p + 1);
  30.         }
  31.     }
  32. }
  33.  
  34. int main() {
  35.     f >> n >> m;
  36.     for(int i = 1; i <=m; ++i) f >> a[i].first >> a[i].second;
  37.     div(1, 1, n, n, 1);
  38.     g << smax;
  39.     g.close();
  40.     return 0;
  41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top