結果

問題 No.13 囲みたい!
ユーザー PulmnPulmn
提出日時 2018-07-24 18:16:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 368 ms / 5,000 ms
コード長 1,309 bytes
コンパイル時間 1,342 ms
コンパイル使用メモリ 152,272 KB
実行使用メモリ 4,512 KB
最終ジャッジ日時 2023-09-05 13:18:17
合計ジャッジ時間 5,358 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 364 ms
4,512 KB
testcase_04 AC 367 ms
4,472 KB
testcase_05 AC 363 ms
4,408 KB
testcase_06 AC 368 ms
4,380 KB
testcase_07 AC 367 ms
4,376 KB
testcase_08 AC 368 ms
4,376 KB
testcase_09 AC 368 ms
4,376 KB
testcase_10 AC 58 ms
4,376 KB
testcase_11 AC 279 ms
4,376 KB
testcase_12 AC 24 ms
4,376 KB
testcase_13 AC 114 ms
4,376 KB
testcase_14 AC 122 ms
4,376 KB
testcase_15 AC 5 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0