제출 #745534

#제출 시각아이디문제언어결과실행 시간메모리
745534MohamedAliSaidaneRectangles (IOI19_rect)C++14
10 / 100
23 ms11720 KiB
#include <bits/stdc++.h> #include "rect.h" using namespace std; typedef long long ll; typedef vector<int> vi; #define pb push_back #define ff first #define ss second const int nax = 2505; int n, m; vector<vi> A; ll ans = 0ll; int LG[nax]; int spr[nax][nax][12]; int spc[nax][nax][12]; void init() { LG[1] = 0; for(int i = 2; i < nax; i++) LG[i] = LG[i/2] + 1; for(int row = 0; row < n; row++) { for(int col = 0; col < m; col++) spr[row][col][0] = spc[col][row][0] = A[row][col]; } for(int j = 1; j < 12; j++) { for(int row = 0; row < n; row++) { for(int col = 0; col < m; col++) { spr[row][col][j] = max(spr[row][col][j - 1], spr[row][col + (1 << (j - 1))][j - 1]); spc[col][row][j] = max(spc[col][row][j - 1], spc[col][row + (1 << (j - 1))][j - 1]); } } } } int maxir(int row, int l, int r) { int j = LG[r - l + 1]; return max(spr[row][l][j], spr[row][r - (1 << j) + 1][j]); } int maxic(int col, int l, int r) { int j = LG[r - l + 1]; return max(spc[col][l][j], spc[col][r - (1 << j) + 1][j]); } ll count_rectangles(vector<vi> a) { n = a.size(); m = a[0].size(); A= a; if(n <= 2 || m <= 2) return 0ll; init(); int pref[m + 1]; memset(pref, 0, sizeof(pref)); for(int i = 0; i < m; i ++) { pref[i + 1] = pref[i] + (min(A[0][i], A[2][i]) <= A[1][i]); } for(int i = 1; i < m - 1; i++) { for(int j = i; j < m - 1; j++) { if(pref[j + 1] - pref[i] == 0) { if(min(A[1][i - 1], A[1][j + 1]) > maxir(1, i, j)) 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...