Submission #252625

#TimeUsernameProblemLanguageResultExecution timeMemory
252625Dilshod_ImomovRectangles (IOI19_rect)C++17
0 / 100
2801 ms504 KiB
# include <bits/stdc++.h>
# include "rect.h"
# define ll long long
using namespace std;

const int N = 707;

// bool dp[N][N][N]; // dp[i][j][i1] = 0/1; 1-> can create a rect starting from i,j ending at i1, j

long long count_rectangles(vector<vector<int> > a) {
	int n = a.size(), m = a[0].size(), ans = 0;
	for ( int i = 1; i < n - 1; i++ ) {
		for ( int j = 1; j < m - 1; j++ ) {
			for ( int i1 = i; i1 < n - 1; i1++ ) {
				for ( int j1 = j; j1 < m - 1; j1++ ) {
					int ok = 1;
					for ( int x = i; x <= i1; x++ ) {
						for ( int y = j; y <= j1; y++ ) {
							int A = a[i - 1][y], B = a[i1 + 1][y];
							int C = a[x][j - 1], D = a[x][j1 + 1];
							int z = a[x][y];
							if ( z > A || z > B || z > C || z > D ) {
								ok = 0;
								break;
							}
						}
						if ( !ok ) {
							break;
						}
					}
					ans += ok;
				}
			}
		}
	}
	return ans;
}
/*
int32_t main() {
	int n, m;
	cin >> n >> m;
	vector < vector < int >  > a;
	for ( int i = 0; i < n; i++ ) {
		vector < int > vc; 
		for ( int j = 0; j < m; j++ ) {
			int x;
			cin >> x;
			vc.push_back( x );
		}
		a.push_back( vc );
	} 
	cout << count_rectangles(a);
}
/*
6 5
4  8  7  5  6
7  4  10 3  5
9  7  20 14 2
9  14 7  3  6
5  7  5  2  7
4  5  13 5  6
*/

Compilation message (stderr)

rect.cpp:54:1: warning: "/*" within comment [-Wcomment]
 /*
#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...