이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m;
vector<pair<int, int> > topLeft;
vector<pair<int, int> > bottomRight;
vector<vector<int> > board;
bool works(int startx, int endx, int starty, int endy) {
if (startx > endx or starty > endy)
{
return false;
}
for (int x = startx; x <= endx; x++)
{
for (int y = starty; y <= endy; y++)
{
if (board[x][y] >= board[startx-1][y] or board[x][y] >= board[endx+1][y] or board[x][y] >= board[x][starty-1] or board[x][y] >= board[x][endy+1])
{
return false;
}
}
}
//cout << startx << "," << starty << " to " << endx << "," << endy << "\n";
return true;
}
ll count_rectangles(vector<vector<int> > a) {
n = a.size();
m = a[0].size();
board = a;
for (int i = 1; i < n - 1; i++)
{
for (int j = 1; j < m - 1; j++)
{
if (a[i][j] < a[i-1][j] and a[i][j] < a[i][j-1])
{
topLeft.push_back({i,j});
//cout << "Top left could be " << i << "," << j << "\n";
}
if (a[i][j] < a[i+1][j] and a[i][j] < a[i][j+1])
{
bottomRight.push_back({i,j});
//cout << "Bottom right could be " << i << "," << j << "\n";
}
}
}
ll totalCount = 0;
for (auto i : topLeft)
{
for (auto j : bottomRight)
{
//cout << "Trying " << i.first << "," << i.second << " to " << j.first << "," << j.second << "\n";
totalCount += works(i.first,j.first, i.second, j.second);
}
}
return totalCount;
}
# | 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... |