이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rect.h"
#include<bits/stdc++.h>
#define vi vector<int>
#define pi pair<int,int>
using namespace std;
const int siz = 2502;
vector<pi> con[siz][siz];
bool vis[siz][siz];
vector<vi> A;
int n,m;
#define ckmin(a,b) a=min(a,b);
#define ckmax(a,b) b = max(a,b);
void dfs(int a, int b, int ora,int orb){
if(a<0 || a>=n || b < 0 || b >= m )return;
if(A[a][b])return;
if(vis[a][b])return;
vis[a][b]=1;
con[ora][orb].push_back({a,b});
for(int i = -1; i < 2; i+=2){
dfs(a+i,b,ora,orb);
dfs(a,b+i,ora,orb);
}
}
bool rect(vector<pi> v){
int minix = n, miniy = m, maxix=-1,maxiy=-1;
for(auto[a,b] : v){
ckmin(minix,a);
ckmin(miniy,b);
ckmax(maxix,a);
ckmax(maxiy,b);
if(a==0 || a == n-1 || b == 0 || b == m-1)return 0;
}
return v.size() == (maxix-minix+1)*(maxiy-miniy+1);
}
long long count_rectangles(std::vector<std::vector<int> > a) {
int ans = 0;
A=a;
n = A.size(), m = A[0].size();
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
dfs(i,j,i,j);
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++)if(con[i][j].size())ans+=rect(con[i][j]);
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
rect.cpp: In function 'bool rect(std::vector<std::pair<int, int> >)':
rect.cpp:27:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
27 | for(auto[a,b] : v){
| ^
rect.cpp:35:18: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
35 | return v.size() == (maxix-minix+1)*(maxiy-miniy+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... |