結果

問題 No.92 逃走経路
ユーザー RonlynesRonlynes
提出日時 2017-08-22 18:38:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 987 bytes
コンパイル時間 1,519 ms
コンパイル使用メモリ 158,988 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 04:46:51
合計ジャッジ時間 1,705 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 4 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 4 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 3 ms
6,944 KB
testcase_16 AC 4 ms
6,940 KB
testcase_17 AC 5 ms
6,940 KB
testcase_18 AC 4 ms
6,940 KB
testcase_19 AC 3 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    8 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
int p[1010][110];//i+1(<K)回道を通ったときにj番目の街にいるかどうか
main(){
    int N,M,K,A[1000],B[1000],C[1000],D[1000];
    cin >> N >> M >> K;
    for(int i = 0;i < M;i++)cin >> A[i] >> B[i] >> C[i];
    for(int i = 0;i < K;i++)cin >> D[i];
    //D[0]と一致する道から行ける町全てにチェック
    for(int i = 0;i < M;i++){
        if(D[0] == C[i]){
            p[0][A[i]] = 1;
            p[0][B[i]] = 1;
        }
    }
    for(int i = 1;i < K;i++){
        for(int j = 0;j < M;j++){
            if(D[i] == C[j]){
                //i-1回目にいる町から行ける町にチェック
                if(p[i-1][A[j]])p[i][B[j]] = 1;
                if(p[i-1][B[j]])p[i][A[j]] = 1;
            }
        }
    }
    cout << accumulate(p[K-1],p[K-1]+101,0) << endl;
    for(int i = 1;i <= 100;i++)if(p[K-1][i])printf("%d ",i);
    cout << endl;
}
0