結果

問題 No.92 逃走経路
ユーザー tktk_snsntktk_snsn
提出日時 2021-04-27 22:29:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 1,146 bytes
コンパイル時間 889 ms
コンパイル使用メモリ 91,604 KB
実行使用メモリ 4,440 KB
最終ジャッジ日時 2023-09-20 22:44:12
合計ジャッジ時間 2,355 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <vector>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if (a < b){ a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b){ if (a > b){ a = b; return true; } return false; }

set<int> G[101][101];
int dp[101][1001];

int main() {
    int n, m, k;
    cin >> n >> m >> k;
    for (int i=0;i<m;++i) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        G[a][b].insert(c);
        G[b][a].insert(c);
    }
    for(int i=0; i<n; ++i) dp[i][0] = 1;
    for(int i=0; i<k; ++i) {
        int d; cin >> d;
        for (int s=0; s<n; ++s) {
            if (!dp[s][i]) continue;
            for (int t=0; t<n; ++t) {
                if (G[s][t].find(d) != G[s][t].end()) dp[t][i+1] = 1;
            }
        }
    }
    vector<int> ans;
    for(int i=0; i<n; ++i) if (dp[i][k]) ans.push_back(i+1);
    cout << ans.size() << endl;
    for(int i=0; i<ans.size(); ++i) {
        if(i) cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}
0