結果

問題 No.92 逃走経路
ユーザー RonlynesRonlynes
提出日時 2017-08-22 18:38:10
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,150 bytes
コンパイル時間 367 ms
コンパイル使用メモリ 55,124 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 04:46:48
合計ジャッジ時間 1,017 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <numeric>
using namespace std;

int main(void){
    int n, m, k;
    cin >> n >> m >> k;
    int A[1004], B[1004], C[1004], D[1004];
    int dp[1010][110];
    for(int i=0; i<m; i++){
        cin >> A[i] >> B[i] >> C[i];
    }
    for(int i=0; i<k; i++){
        cin >> D[i];
    }
    for(int i=0;i<m;i++){
        if(C[i] == D[0]){
            dp[0][A[i]] = 1;
            dp[0][B[i]] = 1;
        }
    }
    for(int i=1; i<k; i++){
        for(int j=0; j<m; j++){
            if(C[j] == D[i]){
                if(dp[i-1][A[j]]){
                    dp[i][B[j]] = 1;
                }
                if(dp[i-1][B[j]]){
                    dp[i][A[j]] = 1;
                }
            }
        }
    }
    int max;
    cout << accumulate(dp[k-1], dp[k-1]+101, 0) << endl;
    for(int i=1; i<=100; i++){
        if(dp[k-1][i]){
            cout << i << " ";
        }
    }
    cout << endl;
    // for(int i=1; i<=100; i++){
    //     if(dp[k-1][i]){
    //         cout << i;
    //         if(i != max){
    //             cout << " ";
    //         }
    //     }
    // }
    // cout << endl;

    return 0;
}
0