이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//#include "rect.h"
#include <bits/stdc++.h>
using namespace std;
bool satisfysub6(vector <vector <int> > a,int n,int m){
for (int i=0; i<n; i++){
for (int j=0; j<m; j++){
if (a[i][j]!=0&&a[i][j]!=1) return 0;
}
}
return 1;
}
long long count_rectangles(vector <vector <int> > a){
int n=a.size(),m=a[0].size();
long long ans=0;
if (satisfysub6(a,n,m)){
for (int r1=1; r1<=n-2; r1++){
for (int c1=1; c1<=m-2; c1++){
if (a[r1][c1]) continue;
int r2=r1,c2=c1;
while (r2<n-2&&!a[r2+1][c1]) r2++;
while (c2<m-2&&!a[r1][c2+1]) c2++;
for (int i=r1; i<=r2; i++){
for (int j=c1; j<=c2; j++){
if (a[i][j]) goto die1;
}
}
for (int i=c1; i<=c2; i++){
if (!a[r1-1][i]||!a[r2+1][i]) goto die1;
}
for (int i=r1; i<=r2; i++){
if (!a[i][c1-1]||!a[i][c2+1]) goto die1;
}
ans++;
die1:;
}
}
return ans;
}else {
for (int r1=1; r1<=n-2; r1++){
for (int r2=r1; r2<=n-2; r2++){
for (int c1=1; c1<=m-2; c1++){
for (int c2=c1; c2<=m-2; c2++){
for (int i=r1; i<=r2; i++){
for (int j=c1; j<=c2; j++){
if (a[i][j]>=a[i][c1-1]||a[i][j]>=a[i][c2+1]||a[i][j]>=a[r1-1][j]||a[i][j]>=a[r2+1][j]) goto die;
}
}
ans++;
die:;
}
}
}
}
}
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... |