結果
| 問題 |
No.92 逃走経路
|
| コンテスト | |
| ユーザー |
m1025o1184t
|
| 提出日時 | 2019-12-28 20:38:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 5,000 ms |
| コード長 | 852 bytes |
| コンパイル時間 | 1,622 ms |
| コンパイル使用メモリ | 169,040 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 12:57:17 |
| 合計ジャッジ時間 | 2,306 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
int p[1010][110];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m, k;
cin >> n >> m >> k;
vector<int> a(1000), b(1000), c(1000), d(1000);
rep(i, m) cin >> a[i] >> b[i] >> c[i];
rep(i, k) cin >> d[i];
for (int i = 0; i < m; ++i) {
if (d[0] == c[i]) {
p[0][a[i]] = 1;
p[0][b[i]] = 1;
}
}
for (int i = 1; i < k; ++i) {
for (int j = 0; j < m; ++j) {
if (d[i] == c[j]) {
if (p[i - 1][a[j]]) p[i][b[j]] = 1;
if (p[i - 1][b[j]]) p[i][a[j]] = 1;
}
}
}
int ans = accumulate(p[k - 1], p[k - 1] + 101, 0);
dunk(ans);
for (int i = 1; i <= 100; ++i) {
if (p[k - 1][i]) cout << i << ' ';
}
cout << endl;
return 0;
}
m1025o1184t