結果
| 問題 | No.92 逃走経路 |
| コンテスト | |
| ユーザー |
nenuon
|
| 提出日時 | 2017-06-22 14:00:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 5,000 ms |
| コード長 | 1,147 bytes |
| 記録 | |
| コンパイル時間 | 901 ms |
| コンパイル使用メモリ | 98,536 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-02 12:12:21 |
| 合計ジャッジ時間 | 1,675 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 |
ソースコード
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef pair<int, long long> P;
int main(){
int n,m,k;
cin >> n >> m >> k;
vector<vector<P> > g(n+1);
FOR(i,0,m){
int a, b;
long long c;
cin >> a >> b >> c;
g[a].push_back(P(b,c));
g[b].push_back(P(a,c));
}
long long d[k];
FOR(i,0,k){
cin >> d[i];
}
bool dp[k+1][n+1];
FOR(i,0,k+1){
FOR(j,0,n+1){
if(i == 0) dp[i][j] = true;
else dp[i][j] = false;
}
}
FOR(i,0,k){
FOR(j,0,n+1){
if(!dp[i][j]) continue;
for(auto to : g[j]){
if(to.second == d[i]){
dp[i+1][to.first] = true;
}
}
}
}
vector<int> ans;
FOR(i,1,n+1){
if(dp[k][i]){
ans.push_back(i);
}
}
cout << ans.size() << endl;
FOR(i,0,ans.size()){
printf("%d%c", ans[i], i == ans.size() - 1 ? '\n' : ' ');
}
return 0;
}
nenuon