結果

問題 No.92 逃走経路
ユーザー llllll
提出日時 2018-04-24 02:02:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 1,446 bytes
コンパイル時間 972 ms
コンパイル使用メモリ 101,244 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 23:22:11
合計ジャッジ時間 2,291 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

struct Town {
    ll from, to, cost;
};

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N, M, K;
    bool dp[107][1007];
    for (int i = 0; i < 107; i++) {
        for (int j = 0; j < 1007; j++) {
            if (j == 0) {
                dp[i][j] = true;
            } else {
                dp[i][j] = false;
            }
        }
    }

    cin >> N >> M >> K;

    vector<Town> graph;
    for (int i = 0; i < M; i++) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        graph.push_back(Town{a, b, c});
        graph.push_back(Town{b, a, c});
    }

    for (int i = 1; i <= K; i++) {
        ll d;
        cin >> d;
        for (auto t : graph) {
            if (t.cost == d && dp[t.from][i - 1]) {
                dp[t.to][i] = true;
            }
        }
    }

    vector<int> ans;
    for (int i = 0; i < N; i++) {
        if (dp[i][K]) {
            ans.push_back(i);
        }
    }
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
        if (i > 0) {
            cout << " ";
        }
        cout << (ans[i] + 1);
    }
    cout << endl;

    return 0;
}
0