結果
問題 | No.92 逃走経路 |
ユーザー |
![]() |
提出日時 | 2020-12-09 01:48:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 31 ms / 5,000 ms |
コード長 | 791 bytes |
コンパイル時間 | 2,358 ms |
コンパイル使用メモリ | 205,660 KB |
最終ジャッジ日時 | 2025-01-16 20:27:36 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M, K; cin >> N >> M >> K; vector<vector<pair<int, int>>> G(N); for (int i = 0; i < M; i++) { int a, b, c; cin >> a >> b >> c; a--, b--; G[a].emplace_back(make_pair(b, c)); G[b].emplace_back(make_pair(a, c)); } vector<int> D(K); for (auto &&e : D) { cin >> e; } set<int> st; for (int i = 0; i < N; i++) { st.insert(i); } for (int k = 0; k < K; k++) { set<int> nst; for (auto &u : st) { for (auto &[v, c] : G[u]) { if (D[k] == c) nst.insert(v); } } swap(st, nst); } cout << st.size() << '\n'; for (const auto &e : st) { cout << e + 1 << ' '; } cout << '\n'; return 0; }