Submission #200935

#TimeUsernameProblemLanguageResultExecution timeMemory
200935LawlietRectangles (IOI19_rect)C++17
15 / 100
74 ms46076 KiB
#include <bits/stdc++.h> #include "rect.h" using namespace std; typedef long long int lli; const int MAXN = 90; int n, m; int v[MAXN][MAXN]; bool counted[MAXN][MAXN][MAXN][MAXN]; bool isAnswer(int x1, int y1, int x2, int y2) { if( counted[x1][y1][x2][y2] ) return false; for(int i = x1 ; i <= x2 ; i++) { for(int j = y1 ; j <= y2 ; j++) { if( v[i][j] >= v[i][y1 - 1] || v[i][j] >= v[i][y2 + 1] ) return false; if( v[i][j] >= v[x1 - 1][j] || v[i][j] >= v[x2 + 1][j] ) return false; } } counted[x1][y1][x2][y2] = true; return true; } long long count_rectangles(vector< vector<int> > a) { n = a.size(); m = a[0].size(); for(int i = 0 ; i < n ; i++) for(int j = 0 ; j < m ; j++) v[i][j] = a[i][j]; lli ans = 0; for(int i = 0 ; i < n ; i++) { for(int j = 0 ; j < m ; j++) { int L, R; int up, down; L = R = up = down = -1; for(int k = 0 ; k < j ; k++) if( v[i][k] >= v[i][j] ) L = k; for(int k = m - 1 ; k > j ; k--) if( v[i][k] > v[i][j] ) R = k; for(int k = 0 ; k < i ; k++) if( v[k][j] >= v[i][j] ) up = k; for(int k = n - 1 ; k > i ; k--) if( v[k][j] > v[i][j] ) down = k; if( L == -1 || R == -1 || up == -1 || down == -1 ) continue; if( isAnswer( up + 1 , L + 1 , down - 1 , R - 1 ) ) ans++; } } return ans; }
#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...