結果
問題 | No.92 逃走経路 |
ユーザー |
![]() |
提出日時 | 2017-08-22 17:36:23 |
言語 | C++11 (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,859 bytes |
コンパイル時間 | 788 ms |
コンパイル使用メモリ | 75,748 KB |
実行使用メモリ | 233,424 KB |
最終ジャッジ日時 | 2024-10-15 04:23:54 |
合計ジャッジ時間 | 13,136 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 2 |
other | TLE * 1 -- * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:21:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | scanf("%d %d %d",&n,&m,&k); | ~~~~~^~~~~~~~~~~~~~~~~~~~~ main.cpp:25:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | scanf("%d %d %d", &a, &b, &c); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:41:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 41 | scanf("%d", &d[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <iostream> #include <vector> #include <set> #include <algorithm> using namespace std; struct edge{ int to, from, cost; }; bool comp(const edge& e1, const edge& e2){ if(e1.cost < e2.cost){ return true; }else{ return false; } } int main(void){ int n, m, k, d[1001]; vector<edge> e; scanf("%d %d %d",&n,&m,&k); for(int i=0; i<m; i++){ int a, b, c; scanf("%d %d %d", &a, &b, &c); edge e1, e2; e1.from = a; e1.to = b; e1.cost = c; e2.from = b; e2.to = a; e2.cost = c; e.push_back(e1); e.push_back(e2); } sort(e.begin(), e.end(), comp); for(int i=0; i<k; i++){ scanf("%d", &d[i]); } vector<int> to, tmp; set<int> s; for(int j=0; j<k; j++){ for(int i=0; i<e.size(); i++){ if(e[i].cost == d[j]){ if(j != 0){ for(int l=0; l<to.size(); l++){ if(j == k-1){ if(e[i].from == to[l]){ s.insert(e[i].to); } }else{ if(e[i].from == to[l]){ tmp.push_back(e[i].to); } } } }else{ tmp.push_back(e[i].to); } } } to.clear(); for(int l=0;l<tmp.size(); l++){ to.push_back(tmp[l]); } tmp.clear(); } printf("%ld\n", s.size()); set<int>::iterator ite; for(ite = s.begin(); ite!= s.end(); ite++){ printf("%d",*ite); if(ite != s.end()){ printf(" "); } } printf("\n"); return 0; }