Submission #420763

#TimeUsernameProblemLanguageResultExecution timeMemory
420763SSRSRectangles (IOI19_rect)C++14
15 / 100
68 ms46016 KiB
#include <bits/stdc++.h>
using namespace std;
long long count_rectangles(vector<vector<int>> a){
  int n = a.size();
  int m = a[0].size();
  assert(n <= 80 && m <= 80);
  set<tuple<int, int, int, int>> st;
  for (int i = 1; i < n - 1; i++){
    for (int j = 1; j < m - 1; j++){
      int l = j;
      while (l > 0){
        if (a[i][l - 1] > a[i][j]){
          break;
        }
        l--;
      }
      int r = j + 1;
      while (r < m){
        if (a[i][r] > a[i][j]){
          break;
        }
        r++;
      }
      int u = i;
      while (u > 0){
        if (a[u - 1][j] > a[i][j]){
          break;
        }
        u--;
      }
      int d = i + 1;
      while (d < n){
        if (a[d][j] > a[i][j]){
          break;
        }
        d++;
      }
      if (l > 0 && r < m && u > 0 && d < n){
        bool ok = true;
        for (int x = u; x < d; x++){
          for (int y = l; y < r; y++){
            if (a[x][y] >= a[x][l - 1]){
              ok = false;
            }
            if (a[x][y] >= a[x][r]){
              ok = false;
            }
            if (a[x][y] >= a[u - 1][y]){
              ok = false;
            }
            if (a[x][y] >= a[d][y]){
              ok = false;
            }
          }
        }
        if (ok){
          st.insert(make_tuple(l, r, u, d));
        }
      }
    }
  }
  return st.size();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...