結果
問題 |
No.92 逃走経路
|
ユーザー |
![]() |
提出日時 | 2023-10-17 14:25:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 97 ms / 5,000 ms |
コード長 | 1,601 bytes |
コンパイル時間 | 1,547 ms |
コンパイル使用メモリ | 121,696 KB |
最終ジャッジ日時 | 2025-02-17 08:10:42 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include<iostream> #include<iomanip> #include<string> #include<algorithm> #include<vector> #include<set> #include<list> #include<queue> #include<math.h> #include<bitset> using ll = long long; using namespace std; int main(){ int n , m, k; cin >> n >> m >> k; vector<vector<int>> list(m, vector<int>(3)); vector<int> fee(k), list1(m); set<int> now, can; for (int i = 0; i < m; i++){ cin >> list[i][1] >> list[i][2] >> list[i][0]; } for (int i = 0; i < k; i++){ cin >> fee[i]; if (i == 0) { for (int j = 0; j < m; j++){ if (fee[0] == list[j][0]){ can.insert(list[j][1]); can.insert(list[j][2]); } } } } sort(list.begin(), list.end(), [](const vector<int> &alpha,const vector<int> &beta){return alpha[0] < beta[0];}); for (int i = 0; i < m; i++) list1[i] = list[i][0]; for (int i = 1; i < k; i++){ int idx = -1; auto itr = lower_bound(list1.begin(), list1.end(), fee[i]); if (itr != list1.end()) idx = distance(list1.begin(), itr); for (int j = idx; j < m; j++){ if (list1[j] == fee[i]){ if (can.find(list[j][1]) != can.end()) now.insert(list[j][2]); if (can.find(list[j][2]) != can.end()) now.insert(list[j][1]); } else break; } can = now; now.clear(); } cout << can.size() << endl; string delim = ""; for (auto x : can){ cout << delim << x; delim = " "; } cout << endl; }