結果
| 問題 |
No.2948 move move rotti
|
| コンテスト | |
| ユーザー |
たたき@競プロ
|
| 提出日時 | 2024-10-26 03:09:04 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 200 ms / 4,000 ms |
| コード長 | 1,002 bytes |
| コンパイル時間 | 5,238 ms |
| コンパイル使用メモリ | 311,184 KB |
| 実行使用メモリ | 7,424 KB |
| 最終ジャッジ日時 | 2024-10-26 03:09:13 |
| 合計ジャッジ時間 | 7,818 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint998244353; //1000000007;
using ll=long long;
using pp=pair<int,int>;
#define sr string
#define vc vector
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int main(){
int n,m,k;cin>>n>>m>>k;
vc<int>x(k); rep(i,k)cin>>x[i],x[i]--;
vc v(n,vc<int>(0));
rep(i,m){
int a,b;cin>>a>>b;
a--;b--;
v[a].pb(b);v[b].pb(a);
}
int t=1<<n;
vc dp(k,vc<int>(t,0));
rep(i,k)dp[i][1<<x[i]]=1<<x[i];
rep(z,n){
int ans=t-1;
rep(i,k){
int now=0;
rep(j,t)now|=dp[i][j];
ans&=now;
}
if(ans){
cout<<"Yes";
return 0;
}
vc pre(k,vc<int>(t,0));
swap(pre,dp);
rep(i,k)rep(j,t)rep(s,n)if(pre[i][j]>>s&1)for(auto au:v[s])if(~j>>au&1)dp[i][j^1<<au]|=1<<au;
}
cout<<"No";
}
たたき@競プロ