結果

問題 No.92 逃走経路
ユーザー she11codeshe11code
提出日時 2015-05-06 03:21:41
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,542 bytes
コンパイル時間 1,365 ms
コンパイル使用メモリ 154,632 KB
実行使用メモリ 614,424 KB
最終ジャッジ日時 2023-09-19 07:07:27
合計ジャッジ時間 15,150 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

struct Edge {
    int to, cost;
};

struct P {
    int town, k;
};

int main() {
    int town_n, road_n, k;
    cin >> town_n >> road_n >> k;
    vector<vector<Edge> > E(town_n + 1);
    REP(i, road_n) {
        int a, b, c;
        cin >> a >> b >> c;
        E[a].push_back({ b, c });
        E[b].push_back({ a, c });
    }
    vi costs(k);
    REP(i, k) cin >> costs[i];

    vi towns;
    queue<P> que;
    REP(i, town_n) {
        que.push({i+1, 0});
    }

    while (!que.empty()) {
        P p = que.front(); que.pop();

        if (p.k == k) {
            towns.push_back(p.town);
        }

        for (Edge& e : E[p.town]) {
            if (e.cost == costs[p.k]) {
                que.push({e.to, p.k+1});
            }
        }
    }

    cout << towns.size() << endl;
    cout << towns[0];
    FOR(i, 1, towns.size()) {
        cout << " " << towns[i];
    }
    cout << endl;
}
0