結果

問題 No.92 逃走経路
ユーザー motumotumotumotu
提出日時 2014-12-07 20:32:25
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 2,074 bytes
コンパイル時間 907 ms
コンパイル使用メモリ 82,020 KB
実行使用メモリ 11,568 KB
最終ジャッジ日時 2023-09-02 09:46:00
合計ジャッジ時間 13,389 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
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 <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <ctime>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define CLEAR(d) memset((d), 0, (sizeof((d))))
#define ALL(c) (c).begin(), (c).end()
#define ABS(x) ((x < 0) ? -(x) : (x))
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).begin(), (x).end(), greater<int>() )
#define SIZE(a) ((int)((a).size()))
#define MOD 1000000007
#define EPS 1e-10
#define PI  (acos(-1))
#define INF 10000000
struct edge { int to; int cost; };
//===================================================

int ans[1001] = {};

void check(vector<edge> e[], vector<int> d, int pos, int cnt)
{
    if (cnt >= d.size()) {
        ans[pos] = 1;
        return;
    }
    for (int i = 0; i < e[pos].size(); i++) {
        if (e[pos][i].cost == d[cnt]) {
            check(e, d, e[pos][i].to, cnt+1);
        }
    }
}

int main()
{
    int n, m, k, a, b, c;
    vector<edge> e[1001];
    cin >> n >> m >> k;
    vector<int> d(k);
    REP(i, m) {
        cin >> a >> b >> c;
        edge e1 = { a, c }, e2 = { b, c };
        e[b].push_back(e1);
        e[a].push_back(e2);
    }
    REP(i, k) {
        cin >> d[i];
    }
    FOR(i, 1, n) {
        REP(j, e[i].size()) {
            if (e[i][j].cost == d[0]) {
                check(e, d, e[i][j].to, 1);
            }
        }
    }
    vector<int> an;
    for (int i = 1; i <= 1000; i++) {
        if (ans[i] == 1) {
            an.push_back(i);
        }
    }
    int size = an.size();
    cout << size << endl;
    REP(i, size) {
        printf("%d", an[i]);
        if (i < size - 1) printf(" ");
    }
    puts("");

    return 0;
}
0