結果
問題 | No.2948 move move rotti |
ユーザー |
|
提出日時 | 2024-07-02 21:29:49 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,084 bytes |
コンパイル時間 | 2,802 ms |
コンパイル使用メモリ | 256,840 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-03 05:51:28 |
合計ジャッジ時間 | 3,854 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 WA * 8 |
ソースコード
#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<bool> dp(n); dp[e]=1; for(int i=0;i<n;i++){ vector<bool> f2(n); for(int p=0;p<n;p++){ if(dp[p])f2[p]=1; } for(int p=0;p<n;p++){ f[i][p]=f[i][p]&&f2[p]; } vector<bool> ndp(n); for(int p=0;p<n;p++){ if(!dp[p])continue; for(auto&&nx:g[p]){ ndp[nx]=1; } } swap(dp,ndp); } } for(auto&&vec:f){ for(auto&&flg:vec){ if(flg){ cout<<"Yes\n"; return 0; } } } cout<<"No\n"; }