# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
824671 | tolbi | Rectangles (IOI19_rect) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 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){
};
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 (!viz[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);
}