結果
| 問題 | 
                            No.92 逃走経路
                             | 
                    
| コンテスト | |
| ユーザー | 
                             cherrypi59
                         | 
                    
| 提出日時 | 2018-10-13 13:31:35 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 783 bytes | 
| コンパイル時間 | 1,769 ms | 
| コンパイル使用メモリ | 169,112 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-12 17:59:55 | 
| 合計ジャッジ時間 | 2,857 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 13 WA * 5 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge {int from, to, cost;};
int d[1005];
ll dp[1005][105];
edge E[1005];
int main(){
    int n, m, k, cnt = 0; cin>>n>>m>>k;
    for(int i=0;i<m;i++) cin>>E[i].from>>E[i].to>>E[i].cost;
    for(int i=0;i<k;i++) cin>>d[i];
    for(int i=1;i<=n;i++) dp[0][i] = 1;
    for(int i=1;i<=k;i++){
        for(auto it:E){
            if(it.cost==d[i-1]){
                dp[i][it.from] += dp[i-1][it.to];
                dp[i][it.to] += dp[i-1][it.from];
            }
        }
    }
    vector<int> ans;
    for(int i=1;i<=n;i++){
        if(dp[k][i]){
            cnt++;
            ans.push_back(i);
        }
    }
    cout<<cnt<<endl;
    for(int it:ans) cout<<it<<' ';
    cout<<endl;
    
    return 0;
}
            
            
            
        
            
cherrypi59