結果
問題 | No.92 逃走経路 |
ユーザー |
![]() |
提出日時 | 2014-12-07 19:48:51 |
言語 | C++11 (gcc 11.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,084 bytes |
コンパイル時間 | 652 ms |
コンパイル使用メモリ | 81,572 KB |
実行使用メモリ | 273,192 KB |
最終ジャッジ日時 | 2024-06-11 16:18:08 |
合計ジャッジ時間 | 13,072 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
ソースコード
#include <iostream> #include <string> #include <map> #include <cmath> #include <algorithm> #include <vector> using namespace std; struct edge{ int from,to,cost; }; vector<vector<edge> >es; vector<int> d; vector<int> ans; void dfs(int v,int k,int maxk){ if(k == maxk)ans.push_back(v); for(int i=0;i<es[v].size();i++){ if(es[v][i].cost == d[k])dfs(es[v][i].to,k+1,maxk); } } int main(void){ int n,m,k; cin >> n >> m >> k; es.resize(n); for(int i=0;i<m;i++){ int a,b,c; cin >> a >> b >> c; a--;b--; es[a].push_back((edge){a,b,c}); es[b].push_back((edge){b,a,c}); } d.resize(k); for(int i=0;i<k;i++){ cin >> d[i]; } for(int i=0;i<n;i++){ dfs(i,0,k); } sort(ans.begin(),ans.end()); vector<int> ret; int pre = -1; for(int i=0;i<ans.size();i++){ if(ans[i] != pre){ //cout << ans[i] << endl; pre = ans[i]; ret.push_back(ans[i]); } } cout << ret.size() << endl; for(int i=0;i<ret.size();i++){ cout << ret[i]+1; if(i != ret.size()-1)cout << " "; } cout << endl; return 0; }