結果

問題 No.92 逃走経路
ユーザー kaffelunkaffelun
提出日時 2018-10-26 22:22:39
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,433 bytes
コンパイル時間 1,448 ms
コンパイル使用メモリ 167,504 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-29 22:06:49
合計ジャッジ時間 2,421 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, M, K;
    set<int64_t> mat[100][100];
    int64_t d[1000];
    int exist[2][100];
    cin >> N >> M >> K;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            mat[i][j] = set<int64_t>();
        }
    }
    for(int i = 0; i < M; i++) {
        int64_t a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        mat[b][a].insert(c);
        mat[a][b].insert(c);
    }
    for(int i = 0; i < K; i++) {
        cin >> d[i];
    }
    for(int i = 0; i < 100; i++) {
        exist[0][i] = 1;
        exist[1][i] = 0;
    }
    for(int k = 0; k < K; k++) {
        int b = k & 1;
        for(int i = 0; i < 100; i++) {
            exist[1-b][i] = 0;
        }
        for(int i = 0; i < N; i++) {
            if(!exist[b][i]) continue;
            for(int j = 0; j < N; j++) {
                if (mat[i][j].count(d[k])) {
                    exist[1-b][j] = 1;
                    break;
                }
            }
        }
    }
    vector<int> ans(0);
    for(int i = 0; i < N; i++) {
        if(exist[K&1][i]) ans.push_back(i + 1);
    }
    cout << ans.size() << endl;
    for(int i = 0; i < ans.size(); i++) {
        cout << ans[i];
        if(i != ans.size() - 1) cout << " ";
    }
    cout << endl;
    return 0;
}
0