Submission #1084343

#TimeUsernameProblemLanguageResultExecution timeMemory
1084343steveonalexRectangles (IOI19_rect)C++17
37 / 100
1254 ms1048576 KiB
#include "rect.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define MASK(i) (1LL << (i)) #define GETBIT(mask, i) (((mask) >> (i)) & 1) #define ALL(v) (v).begin(), (v).end() #define block_of_code if(true) ll max(ll a, ll b){return (a > b) ? a : b;} ll min(ll a, ll b){return (a < b) ? a : b;} ll gcd(ll a, ll b){return __gcd(a, b);} ll lcm(ll a, ll b){return a / gcd(a, b) * b;} ll LASTBIT(ll mask){return (mask) & (-mask);} int pop_cnt(ll mask){return __builtin_popcountll(mask);} int ctz(ull mask){return __builtin_ctzll(mask);} int logOf(ull mask){return 63 - __builtin_clzll(mask);} mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); ll rngesus(ll l, ll r){return l + (ull) rng() % (r - l + 1);} double rngesus_d(double l, double r){ double cur = rngesus(0, MASK(60) - 1); cur /= MASK(60) - 1; return l + cur * (r - l); } template <class T1, class T2> bool maximize(T1 &a, T2 b){ if (a < b) {a = b; return true;} return false; } template <class T1, class T2> bool minimize(T1 &a, T2 b){ if (a > b) {a = b; return true;} return false; } template <class T> void printArr(T container, string separator = " ", string finish = "\n", ostream &out = cout){ for(auto item: container) out << item << separator; out << finish; } template <class T> void remove_dup(vector<T> &a){ sort(ALL(a)); a.resize(unique(ALL(a)) - a.begin()); } ll count_rectangles(vector<vector<int>> a) { int n= a.size(), m = a[0].size(); ll ans = 0; short row_pref[n][n][m], col_pref[m][m][n]; memset(row_pref, 0, sizeof row_pref); memset(col_pref, 0, sizeof col_pref); for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j){ int ma = 0; for(int k = i + 1; k + 1 < n; ++k){ maximize(ma, a[k][j]); if (ma >= a[i][j]) break; if (ma < a[k+1][j]){ row_pref[i][k+1][j] = 1; } } ma = 0; for(int k = j + 1; k + 1 < m; ++k){ maximize(ma, a[i][k]); if (ma >= a[i][j]) break; if (ma < a[i][k+1]){ col_pref[j][k+1][i] = 1; } } } for(int i = 0; i<n; ++i) for(int j = i + 2; j < n; ++j) for(int k = 1; k < m; ++k) row_pref[i][j][k] += row_pref[i][j][k-1]; for(int i = 0; i<m; ++i) for(int j = i + 2; j < m; ++j) for(int k = 1; k < n; ++k) col_pref[i][j][k] += col_pref[i][j][k-1]; for(int i = 0; i<n; ++i) for(int x = i + 2; x < n; ++x) for(int j = 0; j<m; ++j) for(int y = j + 2; y < m; ++y){ int cnt1 = row_pref[i][x][y-1] - row_pref[i][x][j]; int cnt2 = col_pref[j][y][x-1] - col_pref[j][y][i]; if (cnt1 == y - j - 1 && cnt2 == x - i - 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...