結果
問題 |
No.92 逃走経路
|
ユーザー |
![]() |
提出日時 | 2019-04-04 21:31:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,354 bytes |
コンパイル時間 | 1,066 ms |
コンパイル使用メモリ | 98,980 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 06:44:02 |
合計ジャッジ時間 | 3,898 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 5 WA * 4 RE * 9 |
ソースコード
#include<iostream> #include<cstdio> #include<cstring> #include <cstdlib> #include <cmath> #include<cctype> #include<string> #include<set> #include <map> #include<algorithm> #include <functional> #include<vector> #include<climits> #include<stack> #include<queue> #include <deque> #include <climits> #include <typeinfo> #include <utility> #define all(x) (x).begin(),(x).end() #define rep(i,m,n) for(int i = m;i < n;++i) #define pb push_back #define fore(i,a) for(auto &i:a) #define rrep(i,m,n) for(int i = m;i >= n;--i) #define INF INT_MAX/2 using namespace std; using ll = long long; using R = double; const ll MOD = 1e9 + 7; const ll inf = 1LL << 50; struct edge { ll from; ll to; ll cost; }; ll n, m, k; vector<vector<ll>>e[1010]; vector<ll>d; int dfs(int now,int num) { if (num == k)return 1; ll next = d[num]; fore(x,e[next]) { if (x[1] == now) { if (dfs(x[0], num + 1))return 1; } } return 0; } int main(){ cin >> n >> m >> k; rep(i, 0, m) { ll a, b, c; cin >> a >> b >> c; e[c].pb({a,b}); e[c].pb({b,a}); } rep(i, 0, k) { ll D; cin >> D; d.pb(D); } reverse(all(d)); ll ans = 0; vector<ll>town; fore(x,e[d[0]]) { if (dfs(x[0], 1)) { ans++; town.pb(x[1]); } } cout << ans << endl; sort(all(town)); rep(i, 0, ans) { if (i)cout << " "; cout << town[i]; } cout << endl; return 0; }