結果
問題 |
No.92 逃走経路
|
ユーザー |
![]() |
提出日時 | 2021-03-10 13:53:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,090 bytes |
コンパイル時間 | 1,974 ms |
コンパイル使用メモリ | 177,964 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 04:26:10 |
合計ジャッジ時間 | 3,030 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 4 WA * 14 |
ソースコード
#include <bits/stdc++.h> using namespace std; template<typename type1,typename type2> type2 vector_reduce(vector<type1>& v,function<type2(type2,type1)> fn,type2 initial){ int N=v.size(); type2 ans=initial; for(int i=0;i<N;i++){ ans=fn(ans,v[i]); } return ans; } int main(){ int N,M,K; cin>>N>>M>>K; vector<vector<int>> road(0,vector<int>(3)); vector<bool> possible(N+1,true); vector<bool> next(N+1); vector<bool> mask(N+1); possible[0]=false; int a,b,c,d; for(int i=0;i<M;i++){ cin>>a>>b>>c; road.push_back({a,b,c}); road.push_back({b,a,c}); } for(int i=0;i<K;i++){ cin>>d; next=mask; for(int j=0;j<2*M;j++){ if(possible[road[j][0]] && d==road[j][2]){ next[road[j][1]]=true; } } possible=next; } function<int(int,bool)> fn=[](int p,bool a){return p+(a?1:0);}; cout<<vector_reduce(possible,fn,0)<<endl; for(int i=0;i<N;i++){ if(possible[i]){ cout<<i<<" "; } } }