Submission #293743

#TimeUsernameProblemLanguageResultExecution timeMemory
293743egekabasRectangles (IOI19_rect)C++14
15 / 100
76 ms51960 KiB
#include "rect.h" #include <bits/stdc++.h> #define all(x) (x).begin(), (x).end() #define ff first #define ss second #define pb push_back #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> pll; typedef pair<ull, ull> pull; typedef pair<int, int> pii; typedef pair<ld, ld> pld; bitset<100> lef[100][100]; bitset<100> down[100][100]; bitset<100> lefr[100][100][100]; bitset<100> downr[100][100][100]; int n, m; long long count_rectangles(vector<std::vector<int> > a) { n = a.size(); m = a[0].size(); for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j){ int maxi = -1; for(int k = j+1; k < m; ++k){ if(a[i][j] <= maxi) break; lef[i][j][k] = a[i][k] > maxi; maxi = max(maxi, a[i][k]); } } for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j){ int maxi = -1; for(int k = i+1; k < n; ++k){ if(a[i][j] <= maxi) break; down[i][j][k] = a[k][j] > maxi; maxi = max(maxi, a[k][j]); } } for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j) for(int k = j; k < m; ++k){ if(j == k) downr[i][j][k] = down[i][j]; else downr[i][j][k] = (down[i][k]&downr[i][j][k-1]); } for(int i = 0; i < m; ++i) for(int j = 0; j < n; ++j) for(int k = j; k < n; ++k){ if(j == k) lefr[i][j][k] = lef[j][i]; else lefr[i][j][k] = (lef[k][i]&lefr[i][j][k-1]); } ll ans = 0; for(int i1 = 1; i1 < n-1; ++i1) for(int i2 = i1; i2 < n-1; ++i2) for(int j1 = 1; j1 < m-1; ++j1) for(int j2 = j1; j2 < m-1; ++j2){ ans += downr[i1-1][j1][j2][i2+1]&lefr[j1-1][i1][i2][j2+1]; } 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...