結果

問題 No.92 逃走経路
ユーザー cherrypi59cherrypi59
提出日時 2018-10-13 13:31:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 783 bytes
コンパイル時間 1,584 ms
コンパイル使用メモリ 167,480 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 20:01:14
合計ジャッジ時間 2,161 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 5 ms
5,376 KB
testcase_18 AC 5 ms
5,376 KB
testcase_19 AC 4 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0