結果

問題 No.92 逃走経路
ユーザー h_nosonh_noson
提出日時 2016-03-15 12:25:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 31 ms / 5,000 ms
コード長 937 bytes
コンパイル時間 1,182 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 13:19:24
合計ジャッジ時間 1,853 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

#define RREP(i,s,e) for (i = e-1; i >= s; i--)
#define rrep(i,n) RREP(i,0,n)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e8

typedef long long ll;

int main() {
    int i, n, m, k;
    ll d[1000];
    set<int> s[2];
    vector<map<int,vector<int>>> edges;
    cin >> n >> m >> k;
    edges.resize(n+1);
    rep (i,m) {
        int a, b, c;
        cin >> a >> b >> c;
        edges[a][c].push_back(b);
        edges[b][c].push_back(a);
    }
    rep (i,k) cin >> d[i];
    rep (i,n) s[0].insert(i+1);
    rep (i,k) {
        for (int a : s[i%2]) {
            for (int b : edges[a][d[i]])
                s[(i+1)%2].insert(b);
        }
        s[i%2].clear();
    }
    cout << s[k%2].size() << endl;
    for (int a : s[k%2])
        cout << a << " ";
    cout << endl;
    return 0;
}
0