Submission #293744

#TimeUsernameProblemLanguageResultExecution timeMemory
293744egekabasRectangles (IOI19_rect)C++14
27 / 100
1165 ms474232 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<200> lef[200][200];
bitset<200> down[200][200];
bitset<200> lefr[200][200][200];
bitset<200> downr[200][200][200];

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...