結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-05-25 03:54:29 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 9 ms / 5,000 ms |
| コード長 | 929 bytes |
| コンパイル時間 | 638 ms |
| コンパイル使用メモリ | 69,232 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-06 08:10:35 |
| 合計ジャッジ時間 | 1,301 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
int main() {
int n, m, k;
cin >> n >> m >> k;
vector<int> a(m), b(m), c(m);
for (int i = 0; i < m; i++) {
cin >> a[i] >> b[i] >> c[i];
}
vector< vector<bool> > possible(k + 1, vector<bool>(n + 1, false));
fill(possible[0].begin() + 1, possible[0].end(), true);
int d, x, y;
for (int i = 0; i < k; i++) {
cin >> d;
for (int j = 0; j < m; j++) {
if (c[j] == d) {
x = a[j];
y = b[j];
if (possible[i][x]) { possible[i + 1][y] = true; }
if (possible[i][y]) { possible[i + 1][x] = true; }
}
}
}
vector<int> ans;
for (int i = 0; i <= n; i++) {
if (possible[k][i]) {
ans.push_back(i);
}
}
cout << ans.size() << endl;
for (int i = 0; i < ans.size(); i++) {
if (i != 0) {
cout << " ";
}
cout << ans[i];
}
cout << endl;
return 0;
}