結果
問題 | No.92 逃走経路 |
ユーザー |
![]() |
提出日時 | 2018-10-15 16:36:06 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 5,000 ms |
コード長 | 918 bytes |
コンパイル時間 | 2,305 ms |
コンパイル使用メモリ | 202,700 KB |
最終ジャッジ日時 | 2025-01-06 14:33:09 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include<bits/stdc++.h>using namespace std;using Int = long long;template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}//INSERT ABOVE HEREsigned main(){Int n,m,k;cin>>n>>m>>k;using P = pair<Int, Int>;vector<vector<P> > G(n);for(Int i=0;i<m;i++){Int a,b,c;cin>>a>>b>>c;a--;b--;G[a].emplace_back(b,c);G[b].emplace_back(a,c);}vector<Int> d(k);for(Int i=0;i<k;i++) cin>>d[i];vector<Int> dp(n,1);for(Int i=0;i<k;i++){vector<Int> nx(n,0);for(Int v=0;v<n;v++)for(auto [u, c]:G[v])if(d[i]==c) nx[u]|=dp[v];swap(dp,nx);}vector<Int> ans;for(Int i=0;i<n;i++)if(dp[i]) ans.emplace_back(i);cout<<ans.size()<<endl;for(Int i=0;i<(Int)ans.size();i++){if(i) cout<<" ";cout<<ans[i]+1;}cout<<endl;return 0;}