結果
問題 | No.92 逃走経路 |
ユーザー |
![]() |
提出日時 | 2018-04-24 02:02:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 1,446 bytes |
コンパイル時間 | 908 ms |
コンパイル使用メモリ | 102,896 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-27 15:48:01 |
合計ジャッジ時間 | 1,813 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include <algorithm>#include <cmath>#include <cstring>#include <deque>#include <iomanip>#include <iostream>#include <map>#include <numeric>#include <queue>#include <set>#include <string>#include <unordered_map>#include <vector>using namespace std;using ll = long long;struct Town {ll from, to, cost;};int main() {cin.tie(nullptr);ios::sync_with_stdio(false);int N, M, K;bool dp[107][1007];for (int i = 0; i < 107; i++) {for (int j = 0; j < 1007; j++) {if (j == 0) {dp[i][j] = true;} else {dp[i][j] = false;}}}cin >> N >> M >> K;vector<Town> graph;for (int i = 0; i < M; i++) {ll a, b, c;cin >> a >> b >> c;a--;b--;graph.push_back(Town{a, b, c});graph.push_back(Town{b, a, c});}for (int i = 1; i <= K; i++) {ll d;cin >> d;for (auto t : graph) {if (t.cost == d && dp[t.from][i - 1]) {dp[t.to][i] = true;}}}vector<int> ans;for (int i = 0; i < N; i++) {if (dp[i][K]) {ans.push_back(i);}}cout << ans.size() << endl;for (int i = 0; i < ans.size(); i++) {if (i > 0) {cout << " ";}cout << (ans[i] + 1);}cout << endl;return 0;}