제출 #415308

#제출 시각아이디문제언어결과실행 시간메모리
415308peuchRectangles (IOI19_rect)C++17
0 / 100
19 ms8276 KiB
#include "rect.h"
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 210;

int lVal[MAXN][MAXN][MAXN];
int cVal[MAXN][MAXN][MAXN];

long long count_rectangles(std::vector<std::vector<int> > a) {
	int n = a.size();
	int m = a[0].size();
	
	for(int i = 1; i < n - 1; i++){
		for(int j = 1; j < m - 1; j++){
			int maxi = 0;
			for(int k = j; k < m - 1; k++){
				maxi = max(maxi, a[i][k]);
				lVal[i][j][k] = maxi < a[i][j - 1] && maxi < a[i][k + 1];
			}
		}
	}
	for(int i = 1; i < m - 1; i++){
		for(int j = 1; j < n - 1; j++){
			int maxi = 0;
			for(int k = j; k < n - 1; k++){
				maxi = max(maxi, a[k][i]);
				cVal[i][j][k] = maxi < a[j - 1][i] && maxi < a[k + 1][i];
			}
		}
	}
	
	long long ans = 0;
	
	for(int i = 1; i < n - 1; i++){
		for(int j = 1; j < m - 1; j++){
			for(int k = i; k < n - 1; k++){
				for(int l = j; l < m - 1; l++){
					if(cVal[l][i][k] == 0) break;
					bool flag = true;
					for(int a = i; a <= k; a++)
						flag &= lVal[i][j][l];
					ans += flag;
				}
			}
		}
	}
	
	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...