이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rect.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int N,M;
vector<vector<int>> good,row,col,arr;
ll calc(int sr,int sc){
//cerr<<sr<<','<<sc<<endl;
for(int i = sr;i<N;i++)for(int j = sc;j<M;j++)good[i][j] = col[i][j] = row[i][j] = 0;
for(int i = 0;i<N;i++)good[i][sc] = 1;
for(int i = 0;i<M;i++)good[sr][i] = 1;
ll re = 0;
for(int i = sr+1;i+1<N;i++){
for(int j = sc+1;j+1<M;j++){
if(good[i][j-1]&&good[i-1][j]&&arr[i][j]<arr[sr][j]&&arr[i][j]<arr[i][sc])good[i][j] = 1;
if(!good[i][j])break;
row[i][j] = max(row[i][j-1],arr[i][j]);
col[i][j] = max(col[i-1][j],arr[i][j]);
if(arr[i+1][j]>col[i][j]&&arr[i][j+1]>row[i][j])re++;
if(arr[i+1][j]<=col[i][j])break;
}
}
return re;
}
long long count_rectangles(std::vector<std::vector<int> > a) {
N = a.size(),M = a[0].size();
row = col = good = vector<vector<int>>(N,vector<int>(M,0));
arr = a;
ll ans = 0;
for(int i = 0;i+1<N;i++){
for(int j = 0;j+1<M;j++){
ans += calc(i,j);
}
}
return ans;
}
# | 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... |