結果

問題 No.92 逃走経路
ユーザー kimiyukikimiyuki
提出日時 2016-06-21 17:29:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 818 bytes
コンパイル時間 827 ms
コンパイル使用メモリ 90,284 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 23:39:37
合計ジャッジ時間 1,623 ms
ジャッジサーバーID
(参考情報)
judge6 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
#include <map>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
int main() {
    // input
    int n, m, k; cin >> n >> m >> k;
    vector<map<int,vector<int> > > g(n);
    repeat (i,m) {
        int a, b, c; cin >> a >> b >> c; -- a; -- b;
        g[a][c].push_back(b);
        g[b][c].push_back(a);
    }
    vector<int> ds(k); repeat (i,k) cin >> ds[i];
    // search
    set<int> xs; repeat (i,n) xs.insert(i);
    for (int d : ds) {
        set<int> ys;
        for (int x : xs) {
            if (g[x].count(d)) for (int y : g[x][d]) {
                ys.insert(y);
            }
        }
        xs = ys;
    }
    // output
    cout << xs.size() << endl;
    for (int x : xs) cout << x + 1 << ' ';
    cout << endl;
    return 0;
}
0