Advertisement
_rashed

UVA 10667

Jul 14th, 2022
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.56 KB | None | 0 0
  1. #define ll long long
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. const int OO = 1e9;
  6. const double EPS = 1e-9;
  7.  
  8. int arr[105][105];
  9. int pre[105][105];
  10.  
  11. int main()
  12. {
  13.     ios_base::sync_with_stdio(false);
  14.     cin.tie(NULL);
  15.     cout.tie(NULL);
  16.     int t;
  17.     cin >> t;
  18.     while(t--) {
  19.         int s,b;
  20.         cin >> s >> b;
  21.         for(int i = 1; i <= s; i++) {
  22.             for(int j = 1; j <= s; j++) {
  23.                 arr[i][j] = 0;
  24.             }
  25.         }
  26.         for(int bi = 0; bi < b; bi++) {
  27.             int r1,c1,r2,c2;
  28.             cin >> r1 >> c1 >> r2 >> c2;
  29.             for(int r = r1; r <= r2; r++) {
  30.                 for(int c = c1; c <= c2; c++) {
  31.                     arr[r][c] = 1;
  32.                 }
  33.             }
  34.         }
  35.         for(int r = 1; r <= s; r++) {
  36.             int sum = 0;
  37.             for(int c = 1; c <= s; c++) {
  38.                 sum += arr[r][c];
  39.                 pre[r][c] = sum + pre[r-1][c];
  40.             }
  41.         }
  42.         int ans = 0;
  43.         for(int r1 = 1; r1 <= s; r1++) {
  44.             for(int r2 = r1; r2 <= s; r2++) {
  45.                 int sum = 0;
  46.                 for(int c = 1; c <= s; c++) {
  47.                     int curr = pre[r2][c] - pre[r2][c-1] - pre[r1-1][c] + pre[r1-1][c-1];
  48.                     if(curr == 0) {
  49.                         sum += r2-r1+1;
  50.                     }
  51.                     else {
  52.                         sum = 0;
  53.                     }
  54.                     ans = max(ans,sum);
  55.                 }
  56.             }
  57.         }
  58.         cout << ans << "\n";
  59.     }
  60.     return 0;
  61. }
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement