제출 #293742

#제출 시각아이디문제언어결과실행 시간메모리
293742egekabasRectangles (IOI19_rect)C++14
0 / 100
44 ms10872 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){ vector<pii> v; for(int j = m-1; j >= 0; --j){ while(v.size()){ lef[i][j][v.back().ss] = 1; if(v.back().ff > a[i][j]) break; v.pop_back(); } v.pb({a[i][j], j}); } } for(int j = 0; j < m; ++j){ vector<pii> v; for(int i = n-1; i >= 0; --i){ while(v.size()){ down[i][j][v.back().ss] = 1; if(v.back().ff > a[i][j]) break; v.pop_back(); } v.pb({a[i][j], i}); } } 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][j]&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[j][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...