結果

問題 No.92 逃走経路
ユーザー u-shou-sho
提出日時 2017-08-22 19:13:34
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 1,150 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 65,816 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 04:47:23
合計ジャッジ時間 1,259 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <tuple>
#include <numeric>

using namespace std;

int main(){
    int N, M, K, a, b;
    long long c, d;

    cin >> N >> M >> K;

    vector<tuple<int, int, long long>> abc(M);
    for(int i=0; i<M; i++){
        cin >> a >> b >> c;
        abc[i] = make_tuple(a, b, c);
    }

    bool dp[K+1][N+1];
    for(int i=0; i<K+1; i++){
        for(int j=0; j<N+1; j++){
        	dp[i][j] = false;
        }
    }
    
    for(int i=0; i<K; i++){
        cin >> d;
        for(int j=0; j<M; j++){
            if(i==0){
                if(d==get<2>(abc[j])){
                    dp[i][get<0>(abc[j])] = true;
                    dp[i][get<1>(abc[j])] = true;
                }
            }else{
                if(d==get<2>(abc[j])){
                    if(dp[i-1][get<0>(abc[j])]) dp[i][get<1>(abc[j])] = true;
                    if(dp[i-1][get<1>(abc[j])]) dp[i][get<0>(abc[j])] = true;
                }
            }
        }
    }

    cout << accumulate(dp[K-1], dp[K-1]+N+1, 0) << endl;

    for(int j=1; j<N+1; j++){
        if(dp[K-1][j]) cout << j << " ";
    }
    cout << endl;

    return 0;
}
0