結果

問題 No.13 囲みたい!
ユーザー cocolleaguecocolleague
提出日時 2017-02-04 20:00:37
言語 C++11
(gcc 11.4.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 765 bytes
コンパイル時間 1,162 ms
コンパイル使用メモリ 144,504 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-25 20:14:24
合計ジャッジ時間 4,344 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int dfs(int, int, int, int)’:
main.cpp:24:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
static const int INF = 1e8;

int done[110][110];
int a[110][110];
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
int H,W;
int ok = 0;
int dfs(int x,int y,int px,int py){
	if(done[y][x]) return 0;
	done[y][x] = 1;
	for(int i = 0;i < 4; i++){
		int nx = x + dx[i];
		int ny = y + dy[i];
		if(nx == px && ny == py) continue;
		if(a[ny][nx] != a[y][x] ) continue;
		if(done[ny][nx]) ok = 1;
		dfs(nx,ny,x,y);
	}
}

int main(){
	cin >> W >> H;
	for(int i = 1;i <= H; i++){
		for(int j=1; j <= W; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 1; i <= H;i++){
		for(int j = 1 ; j <=W ; j++){
			dfs(j,i,-1,-1);
		}
	}
	cout << (ok?"possible":"impossible") << endl;
}
0