結果
| 問題 |
No.13 囲みたい!
|
| コンテスト | |
| ユーザー |
cocolleague
|
| 提出日時 | 2017-02-04 20:00:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 765 bytes |
| コンパイル時間 | 1,381 ms |
| コンパイル使用メモリ | 157,796 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 06:18:14 |
| 合計ジャッジ時間 | 5,290 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 16 |
コンパイルメッセージ
main.cpp: In function ‘int dfs(int, int, int, int)’:
main.cpp:24:1: warning: control reaches end of non-void function [-Wreturn-type]
24 | }
| ^
ソースコード
#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;
}
cocolleague