結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-03 09:26:54 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,014 bytes |
| コンパイル時間 | 827 ms |
| コンパイル使用メモリ | 82,140 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-21 16:08:31 |
| 合計ジャッジ時間 | 1,639 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | WA * 18 |
ソースコード
#include <iostream>
#include <vector>
#include <map>
#include <set>
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];
--a[i], --b[i];
}
vector<int> d(K);
for (int i = 0; i < K; ++i) cin >> d[i];
vector<vector<bool>> dp(K, vector<bool>(N,false));
for (int i = 0; i < M; ++i) {
if (d[0] == c[i]) {
dp[0][a[i]] = true;
dp[0][b[i]] = true;
}
}
for (int i = 1; i < K; ++i) {
for (int j = 0; j < M; ++j) {
if (d[i] == c[j]) {
if (dp[i - 1][a[j]]) dp[i][b[j]] = true;
if (dp[i - 1][b[j]]) dp[i][a[j]] = true;
}
}
}
int res = 0;
for (int i = 0; i < N; ++i) {
if (dp[K - 1][i]) ++res;
}
cout << res << endl;
for (int i = 0; i < N; ++i) {
if (dp[K - 1][i]) cout << i << " ";
}
cout << endl;
}