結果
| 問題 |
No.13 囲みたい!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-09-16 04:30:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 982 bytes |
| コンパイル時間 | 1,772 ms |
| コンパイル使用メモリ | 175,040 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-22 03:00:50 |
| 合計ジャッジ時間 | 2,495 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
using P = pair<int,int>;
vector<int> G[10000];
vector<bool> color(10000,false);
vector<P> ways={{1,0},{0,1},{-1,0},{0,-1}};
bool dfs(int v,int p=-1){
if(p==-1&&color[v])return false;
if(color[v])return true;
color[v]=true;
for (auto &&i : G[v]){
if (i==p)continue;
return dfs(i,v);
}
return false;
}
int main() {
int M[101][101];
rep(i,101)M[i][0]=-1;
rep(i,101)M[0][i]=-1;
int W,H;cin>>W>>H;
rep(i,H){
rep(j,W){
cin>>M[i+1][j+1];
}
}
rep(i,H){
rep(j,W){
for (auto &&way : ways){
int i_=i+way.first,j_=j+way.second;
if(M[i+1][j+1]==M[i_+1][j_+1]){
G[i*W+j].push_back(i_*W+j_);
}
}
}
}
rep(i,H*W){
if(dfs(i)){
cout<<"possible"<<endl;
return 0;
}
}
cout<<"impossible"<<endl;
}