이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
ID: Sho10
LANG: C++
*/
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll a[2505][2505];
ll count_rectangles(vector<vector<int> >A){
ll n=A.size();
ll m=A[0].size();
ll ans=0;
ll s1=-1;
for(ll i=0;i<n;i++)
for(ll j=0;j<m;j++){
a[i][j]=A[i][j];
if(a[i][j]>=2){
s1=1;
}
}
if(s1==1){
for(ll i=1;i<n-1;i++)
for(ll j=1;j<m-1;j++)
{
for(ll c=i;c<n-1;c++)
for(ll k=j;k<m-1;k++){
for(ll ii=i;ii<=c;ii++)
for(ll jj=j;jj<=k;jj++)
{
if(a[ii][jj]<a[ii][j-1]&&a[ii][jj]<a[i-1][jj]&&a[ii][jj]<a[c+1][jj]&&a[ii][jj]<a[ii][k+1]){
continue;
}else goto Next;
}
ans++;
Next:ans=ans+0;
}
}
}else {
for(ll i=0;i<n;i++)
for(ll j=0;j<m;j++)
a[i+1][j+1]=A[i][j];
ll s[2505][2505];
for(ll i=1;i<=n;i++)
for(ll j=1;j<=m;j++)
s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];
ll l[2505][2505][3];
ll r[2505][2505][3];
for(ll i=n;i>=1;i--)
for(ll j=m;j>=1;j--)
{
ll x=a[i][j];
l[i][j][x]=l[i+1][j][x]+1;
r[i][j][x]=r[i][j+1][x]+1;
}
for(ll i=2;i<n;i++)
for(ll j=2;j<m;j++)
{
if(a[i][j]==1)continue;
ll x,y;
x=i+l[i][j][0]-1;
y=j+r[i][j][0]-1;
ll val=s[x][y]+s[i-1][j-1]-s[x][j-1]-s[i-1][y];
if(val!=0){
continue;
}
if(l[i][j-1][1]<l[i][j][0]) continue;
if(r[i-1][j][1]<r[i][j][0]) continue;
if(l[i][y+1][1]<l[i][j][0]) continue;
if(r[x+1][j][1]<r[i][j][0]) continue;
ans++;
}
}
return ans;
}
/*
int32_t main(){
CODE_START;
cout<<count_rectangles({{1, 1, 1, 1, 1},{0, 0, 0, 0, 0},{1, 0, 1, 1, 1},{1, 1, 1, 1, 1},{1, 1, 1, 1, 1},{1, 1, 1, 1, 1}});
}
*/
컴파일 시 표준 에러 (stderr) 메시지
rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:30:1: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for(ll i=0;i<n;i++)
^~~
rect.cpp:37:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
if(s1==1){
^~
# | 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... |