#include <bits/stdc++.h>
#include "rect.h"
using namespace std;
typedef long long int lli;
const int MAXN = 210;
int n, m;
int v[MAXN][MAXN];
bool isAnswer(int x1, int y1, int x2, int y2)
{
for(int i = x1 ; i <= x2 ; i++)
{
for(int j = y1 ; j <= y2 ; j++)
{
if( v[i][j] >= v[i][y1 - 1] || v[i][j] >= v[i][y2 + 1] ) return false;
if( v[i][j] >= v[x1 - 1][j] || v[i][j] >= v[x2 + 1][j] ) return false;
}
}
return true;
}
long long count_rectangles(vector< vector<int> > a)
{
n = a.size();
m = a[0].size();
for(int i = 0 ; i < n ; i++)
for(int j = 0 ; j < m ; j++)
v[i][j] = a[i][j];
lli ans = 0;
for(int i = 0 ; i < n ; i++)
{
for(int j = 0 ; j < m ; j++)
{
int L, R;
int up, down;
L = R = up = down = -1;
for(int k = 0 ; k < j ; k++)
if( v[i][k] >= v[i][j] ) L = k;
for(int k = m - 1 ; k > j ; k--)
if( v[i][k] > v[i][j] ) R = k;
for(int k = 0 ; k < i ; k++)
if( v[k][j] >= v[i][j] ) up = k;
for(int k = n - 1 ; k > i ; k--)
if( v[k][j] > v[i][j] ) down = k;
if( L == -1 || R == -1 || up == -1 || down == -1 ) continue;
if( isAnswer( up + 1 , L + 1 , down - 1 , R - 1 ) ) ans++;
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
22 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Runtime error |
70 ms |
46460 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |