結果
| 問題 |
No.2948 move move rotti
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2024-10-25 21:30:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 291 ms / 4,000 ms |
| コード長 | 1,084 bytes |
| コンパイル時間 | 4,447 ms |
| コンパイル使用メモリ | 257,120 KB |
| 最終ジャッジ日時 | 2025-02-24 22:48:42 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000000LL
int main(){
int N,M,K;
cin>>N>>M>>K;
vector<int> x(K);
rep(i,K){
cin>>x[i];
x[i]--;
}
vector f(N,vector<bool>(N,false));
rep(i,M){
int u,v;
cin>>u>>v;
u--,v--;
f[u][v] = true;
f[v][u] = true;
}
vector dp(N,vector(1<<N,vector<bool>(N,false)));
rep(i,N){
dp[i][1<<i][i] = true;
}
rep(i,N){
rep(j,1<<N){
rep(k,N){
if(dp[i][j][k]==false)continue;
rep(l,N){
if((j>>l)&1)continue;
if(!f[k][l])continue;
dp[i][j|(1<<l)][l] = true;
}
}
}
}
rep(i,N+1){
{
int ok = 1<<N;
ok--;
rep(j,K){
int Or = 0;
rep(k,1<<N){
if(__builtin_popcount(k)!=i)continue;
rep(l,N){
if(dp[x[j]][k][l]){
Or |= 1<<l;
}
}
}
ok &= Or;
}
if(ok){
cout<<"Yes"<<endl;
return 0;
}
}
}
cout<<"No"<<endl;
return 0;
}
沙耶花