結果
| 問題 |
No.2948 move move rotti
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-02 21:25:47 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,040 ms / 4,000 ms |
| コード長 | 1,281 bytes |
| コンパイル時間 | 2,987 ms |
| コンパイル使用メモリ | 258,048 KB |
| 実行使用メモリ | 8,268 KB |
| 最終ジャッジ日時 | 2024-07-03 05:51:42 |
| 合計ジャッジ時間 | 18,785 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,m,k;cin>>n>>m>>k;
vector<int> x(k);for(auto&e:x)cin>>e,e--;
vector<vector<int>> g(n);
for(int i=0;i<m;i++){
int u,v;cin>>u>>v;
u--;v--;
g[u].push_back(v);
g[v].push_back(u);
}
vector f(n,vector<bool>(n,1));
for(auto&&e:x){
vector dp(1<<n,vector<bool>(n));
dp[1<<e][e]=1;
for(int i=0;i<n;i++){
vector<bool> f2(n);
for(int S=0;S<(1<<n);S++){
for(int p=0;p<n;p++){
if(dp[S][p])f2[p]=1;
}
}
for(int p=0;p<n;p++){
f[i][p]=f[i][p]&&f2[p];
}
vector ndp(1<<n,vector<bool>(n));
for(int S=0;S<(1<<n);S++){
for(int p=0;p<n;p++){
if(!dp[S][p])continue;
for(auto&&nx:g[p]){
if(S>>nx&1)continue;
ndp[S|(1<<nx)][nx]=1;
}
}
}
swap(dp,ndp);
}
}
for(auto&&vec:f){
for(auto&&flg:vec){
if(flg){
cout<<"Yes\n";
return 0;
}
}
}
cout<<"No\n";
}