結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
6,940 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 3 ms
6,944 KB
testcase_15 WA -
testcase_16 AC 4 ms
6,940 KB
testcase_17 AC 5 ms
6,940 KB
testcase_18 AC 3 ms
6,940 KB
testcase_19 AC 3 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:45:9: warning: ‘max’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   45 |         if(i != max){
      |         ^~

ソースコード

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[1004][103];
    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]){
            max = i;
        }
    }
    for(int i=1; i<=100; i++){
        if(dp[k-1][i]){
            cout << i;
        }
        if(i != max){
            cout << " ";
        }
    }
    cout << endl;

    return 0;
}
0