Submission #288922

#TimeUsernameProblemLanguageResultExecution timeMemory
288922mohammadRectangles (IOI19_rect)C++14
0 / 100
71 ms25208 KiB
#include "rect.h" #include<bits/stdc++.h> using namespace std; #define endl "\n" // #define int long long typedef long long ll ; const ll ooo = 1e14 ; const ll oo = 2e9 ; const double PI = acos(-1) ; const ll M = 1e9 + 7 ; const int N = 10000010 ; bool val[2510][2510] , sum[2510][2510]; int r[4] = {1 , -1 , 0 , 0} , c[4] = {0 , 0 , 1 , -1} ; ll count_rectangles(vector<vector<int> > a) { int n = a.size() , m = a[0].size(); ll ans = 0; for(int i = 1 ; i < n - 1 ; ++i){ for(int j = 1 ; j < m - 1 ; ++j){ bool flag = 1 ; for(int k = 0 ; k < 4 ; ++k){ int x = i + r[k] , y = j + c[k]; if(a[i][j] >= a[x][y]){ flag = 0; break; } } if(!flag) continue ; int end = m - 1; for(int i1 = i ; i1 < n - 1 ; ++i1){ if(!(end - j)) break; for(int j1 = j ; j1 < end ; ++j1){ flag = 1 ; if(a[i1][j1] >= min(min(a[i - 1][j1] , a[i1 + 1][j1]) , min(a[i1][j - 1] , a[i1][j1 + 1]))){ end = j1 ; break; }else ans++; } } end = 0; for(int i1 = i ; i1 ; --i1){ if(!(j - end)) break; for(int j1 = j ; j1> end ; --j1){ flag = 1 ; if(i1 == i && j1 == j) continue ; // cout << min(min(a[i1 - 1][j1] , a[i + 1][j1]) // , min(a[i1][j1 - 1] , a[i1][j + 1])) << ' ' << i << ' ' << j << ' ' << i1 << ' ' << j1 << endl; if(a[i1][j1] >= min(min(a[i1 - 1][j1] , a[i + 1][j1]) , min(a[i1][j1 - 1] , a[i1][j + 1]))){ end = j1 ; break; }else 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...