結果
| 問題 |
No.13 囲みたい!
|
| コンテスト | |
| ユーザー |
Pulmn
|
| 提出日時 | 2018-07-24 18:16:11 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 305 ms / 5,000 ms |
| コード長 | 1,309 bytes |
| コンパイル時間 | 1,536 ms |
| コンパイル使用メモリ | 166,896 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-23 08:56:44 |
| 合計ジャッジ時間 | 4,955 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-18;
const ll mod=1e9+7;
const int dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,-1,0,1,-1,1,-1,1};
int w,h;
vvi a,b;
bool dfs(int x,int y,int c){
b[x][y]=c;
bool B=1;
for(int i=0;i<8;i++){
int X=x+dx[i],Y=y+dy[i];
if(X>=0&&X<h&&Y>=0&&Y<w&&b[X][Y]!=c) B&=dfs(X,Y,c);
if(X<0||h<=X||Y<0||w<=Y) B=0;
}
return B;
}
int main(){
cin>>w>>h;
a=vvi(h,vi(w));
for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>a[i][j];
bool B=0;
for(int i=1;i<=1000;i++){
b=a;
for(int j=1;j<h;j++) for(int k=1;k<w;k++){
if(a[j-1][k-1]==i&&a[j-1][k]==i&&a[j][k-1]==i&&a[j][k]==i) B=1;
}
for(int j=0;j<h;j++) for(int k=0;k<w;k++) if(b[j][k]!=i) B|=dfs(j,k,i);
}
if(!B) cout<<"im";
cout<<"possible"<<endl;
}
Pulmn