結果
問題 |
No.92 逃走経路
|
ユーザー |
![]() |
提出日時 | 2019-12-28 20:33:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 854 bytes |
コンパイル時間 | 1,795 ms |
コンパイル使用メモリ | 171,344 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-12 12:51:05 |
合計ジャッジ時間 | 2,872 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 WA * 3 |
ソースコード
#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; } } } ll ans = accumulate(p[k - 1], p[k - 1] + 100, 0); dunk(ans); for (int i = 1; i <= 100; ++i) { if (p[k - 1][i]) cout << i << ' '; } cout << endl; return 0; }