結果
| 問題 |
No.92 逃走経路
|
| ユーザー |
Ronlynes
|
| 提出日時 | 2017-08-22 17:23:36 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,698 bytes |
| コンパイル時間 | 680 ms |
| コンパイル使用メモリ | 72,092 KB |
| 実行使用メモリ | 235,692 KB |
| 最終ジャッジ日時 | 2024-10-15 04:23:21 |
| 合計ジャッジ時間 | 13,230 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | TLE * 1 -- * 17 |
ソースコード
#include <iostream>
#include <vector>
#include <set>
using namespace std;
struct edge{
int to, from, cost;
};
int main(void){
int n, m, k, d[1001];
vector<edge> e;
cin >> n >> m >> k;
for(int i=0; i<m; i++){
int a, b, c;
cin >> 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);
}
for(int i=0; i<k; i++){
cin >> 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){
// cout << j << endl;
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();
}
cout << s.size() << endl;
set<int>::iterator ite;
for(ite = s.begin(); ite!= s.end(); ite++){
cout << *ite;
if(ite != s.end()){
cout << " ";
}
}
cout << endl;
return 0;
}
Ronlynes