結果

問題 No.92 逃走経路
ユーザー Kutimoti_TKutimoti_T
提出日時 2018-01-10 23:22:22
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,305 bytes
コンパイル時間 832 ms
コンパイル使用メモリ 70,856 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 10:41:31
合計ジャッジ時間 1,750 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <sstream>
using namespace std;

#define FOR(i, s, e) for (int i = (s); i <= (e); i++)


int N;
int M;
int K;

struct edge{
    int a;
    int b;
    int cost;
};

edge edges[1000];

int d[1000];

bool dp[1010][110];


int main()
{
    cin >> N >> M >> K;

    FOR(i,0,M - 1)
    {
        int a,b,c;
        cin >> a >> b >> c;

        edges[i].a = a;
        edges[i].b = b;
        edges[i].cost = c;
    }

    FOR(i,0,K - 1)
    {
        cin >> d[i];
    }

    FOR(i,0,1009)
    {
        FOR(j,0,109)
        {
            dp[i][j] = false;
        }
    }

    FOR(i,0,109)
    {
        dp[0][i] = true;
    }

    FOR(i,0,K - 1)
    {
        FOR(j,0,M - 1)
        {
            edge& e = edges[i];
            if(e.cost == d[i])
            {
                if(dp[i][e.b])
                    dp[i + 1][e.a] = true;
                if(dp[i][e.a])
                    dp[i + 1][e.b] = true;
            }
        }
    }

    stringstream result;
    int cou = 0;

    FOR(i,1,N)
    {
        if(dp[K][i])
        {
            result << i << " ";
            cou++;
        }
    }

    cout << cou << endl;
    cout << result.str() << endl;
    return 0;
}
0