結果
| 問題 |
No.13 囲みたい!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-17 00:41:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 779 bytes |
| コンパイル時間 | 1,397 ms |
| コンパイル使用メモリ | 166,780 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-04 02:47:00 |
| 合計ジャッジ時間 | 2,209 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 10 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int mat[111][111];
int w,h;
void yes(){
cout<<"possible"<<endl;
exit(0);
}
int sgn[111][111];
int seen;
int lstep=0;
void dfs(int y,int x,int step){
if (y<0||x<0||h<=y||w<=x) return ;
if (mat[y][x]!=seen) return ;
if (sgn[y][x]!=0){
if (sgn[y][x]==step) return ;
else yes();
}
sgn[y][x]=++step;
lstep=max(lstep,step);
dfs(y-1,x,step);
dfs(y+1,x,step);
dfs(y,x-1,step);
dfs(y,x+1,step);
return ;
}
int main(){
cin>>w>>h;
for(int y=0;y<h;++y){
for(int x=0;x<w;++x){
scanf("%d",&(mat[y][x]));
}}
int t=0;
for(int y=0;y<h;++y){
for(int x=0;x<w;++x){
if(sgn[y][x]==0){
seen=mat[y][x];
dfs(y,x,lstep);
}
}
}
cout<<"impossible"<<endl;
return 0;
}