This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
#include <stack>
#include <bitset>
#include "rect.h"
using namespace std;
#define ll long long
//cin.tie(0);ios_base::sync_with_stdio(0);
const int MAXN = 2505;
int grid[MAXN][MAXN];
int n, m;
ll ans1() {
if (n == 1 || n == 2) {
return 0;
}
int cnt = 0;
for (int i = 1; i < m - 1; i++) {
int cur = grid[1][i - 1];
int mx = grid[1][i];
for (int j = i; j < m - 1; j++) {
mx = max(mx, grid[1][j]);
if (grid[1][j] >= cur || grid[1][j] >= grid[0][j] || grid[1][j] >= grid[2][j] || grid[1][j] >= grid[1][j + 1] || mx >= grid[1][j + 1] || mx >= cur) {
continue;
}
cnt++;
}
}
return cnt;
}
ll 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++) {
grid[i][j] = a[i][j];
}
}
if (n <= 3) {
return ans1();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |