結果
問題 | No.92 逃走経路 |
ユーザー |
![]() |
提出日時 | 2020-03-26 00:25:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 1,093 bytes |
コンパイル時間 | 2,513 ms |
コンパイル使用メモリ | 202,124 KB |
最終ジャッジ日時 | 2025-01-09 10:11:46 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include<bits/stdc++.h> using lint=long long; int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); std::cout.setf(std::ios_base::fixed);std::cout.precision(15); lint n,m,k;std::cin>>n>>m>>k; std::vector<std::vector<std::pair<lint,lint>>>g(n); while(m--){ lint a,b,c;std::cin>>a>>b>>c;a--,b--; g.at(a).emplace_back(b,c); g.at(b).emplace_back(a,c); } std::vector<lint>dp(n,true); while(k--){ lint x;std::cin>>x; std::vector<lint>swp(n,false); for(lint i=0;i<n;i++){ if(!dp.at(i))continue; for(auto&&e:g.at(i)){ lint j,c;std::tie(j,c)=e; if(c!=x)continue; swp.at(j)=true; } } swp.swap(dp); } std::cout<<std::count(dp.begin(),dp.end(),true)<<'\n'; std::vector<lint>ans; for(lint i=0;i<n;i++){ if(!dp.at(i))continue; ans.push_back(i+1); } lint sz=ans.size(); for(lint i=0;i<sz;i++){ std::cout<<(i?" ":"")<<ans.at(i); } std::cout<<'\n'; }