이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma optimize("Bismillahirrahmanirrahim")
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█■█
//█─█─█▄─█▄─█─█─█─█
//Allahuekber
//ahmet23 orz...
//FatihSultanMehmedHan
//YavuzSultanSelimHan
//AbdulhamidHan
//Sani buyuk Osman Pasa Plevneden cikmam diyor
#define author tolbi
#include <bits/stdc++.h>
using namespace std;
template<typename X, typename Y> istream& operator>>(istream& is, pair<X,Y> &pr){return is>>pr.first>>pr.second;}
template<typename X, typename Y> ostream& operator<<(ostream& os, pair<X,Y> pr){return os<<pr.first<<" "<<pr.second;}
template<typename T> istream& operator>>(istream& is, vector<T> &arr){for (auto &it : arr) is>>it; return is;}
template<typename T> ostream& operator<<(ostream& os, vector<T> arr){for (auto &it : arr) os<<it<<" "; return os;}
template<typename T,size_t Y> istream& operator>>(istream& is, array<T,Y> &arr){for (auto &it : arr) is>>it; return is;}
template<typename T,size_t Y> ostream& operator<<(ostream& os, array<T,Y> arr){for (auto &it : arr) os<<it<<" "; return os;}
#define deci(x) int x;cin>>x;
#define decstr(x) string x;cin>>x;
#define cinarr(x) for (auto &it : x) cin>>it;
#define coutarr(x) for (auto &it :x) cout<<it<<" ";cout<<endl;
#define sortarr(x) sort(x.begin(), x.end())
#define sortrarr(x) sort(x.rbegin(), x.rend())
#define rev(x) reverse(x.begin(), x.end())
#define tol(bi) (1LL<<((int)(bi)))
typedef long long ll;
const int MOD = 1e9+7;
mt19937 ayahya(chrono::high_resolution_clock().now().time_since_epoch().count());
#include "rect.h"
ll subtask6(vector<vector<int>> &arr){
int n = arr.size();
int m = arr[0].size();
vector<vector<bool>> vis(n,vector<bool>(m,false));
ll ans = 0;
function<void(int,int)> dfs;
dfs = [&](int x, int y){
if (x<0 || x>=n || y<0 || y>=m) return;
if (arr[x][y]==1) return;
if (vis[x][y]) return;
vis[x][y]=true;
dfs(x-1,y);
dfs(x+1,y);
dfs(x,y-1);
dfs(x,y+1);
};
for (int i = 0; i < n; i++){
for (int j = 0; j < m; j++){
if (arr[i][j]==1) continue;
if (vis[i][j]) continue;
int rx = i;
bool boolean=true;
for (int z = i; z < n; z++){
if (vis[z][j]){
boolean=false;
break;
}
if (arr[z][j]==1) break;
rx=z;
}
int ry=j;
for (int z = j; z < m; z++){
if (vis[i][z]){
boolean=false;
break;
}
if (arr[i][z]==1) break;
ry=z;
}
if (i==0 || i==n-1 || j==0 || j==m-1) boolean=false;
if (rx==0 || rx==n-1 || ry==0 || ry==m-1) boolean=false;
if (boolean==false){
dfs(i,j);
continue;
}
for (int x = i; x <= rx; x++){
for (int y = j; y <= ry; y++){
if (arr[x][y]!=0){
boolean=false;
break;
}
}
if (!boolean) break;
}
for (int x = i; x <= rx; i++){
if (arr[x][j-1]!=1)boolean=false;
if (arr[x][ry+1]!=1)boolean=false;
}
for (int y = j; y <= ry; y++){
if (arr[i-1][y]!=1)boolean=false;
if (arr[rx+1][y]!=1)boolean=false;
}
if (boolean) ans++;
dfs(i,j);
}
}
return ans;
}
long long count_rectangles(vector<vector<int> > a) {
return subtask6(a);
}
컴파일 시 표준 에러 (stderr) 메시지
rect.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
1 | #pragma optimize("Bismillahirrahmanirrahim")
|
# | 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... |