結果
| 問題 | No.92 逃走経路 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-20 16:27:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 121 ms / 5,000 ms |
| コード長 | 1,058 bytes |
| 記録 | |
| コンパイル時間 | 961 ms |
| コンパイル使用メモリ | 89,184 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 14:42:53 |
| 合計ジャッジ時間 | 2,332 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#include<iostream>
#include<map>
#include<vector>
#include<set>
using namespace std;
int main(){
int n, m, k, a, b, c;
cin >> n >> m >> k;
map<int, vector<pair<int,int>>> pay;
for(int i = 0; i < m; i++){
cin >> a >> b >> c;
pay[c].push_back(make_pair(a,b));
pay[c].push_back(make_pair(b,a));
}
set<int> pos;
cin >> a;
for(pair<int,int> p : pay[a]){
pos.insert(p.second);
}
for(int i = 1; i < k; i++){
cin >> a;
set<int> after;
for(int j = 0; j < pay[a].size(); j++){
pair<int,int> p = pay[a][j];
if(pos.find(p.first)!=pos.end()) after.insert(p.second);
}
pos = after;
// cout << "after " << a << endl;
// for(auto p : pos){
// cout << p << endl;
// }
}
set<int>::iterator it = pos.begin();
cout << pos.size() << endl;
for(int i = 0; i < pos.size(); i++){
if(i) cout << " ";
cout << *it;
it++;
}
cout << endl;
return 0;
}