結果

問題 No.92 逃走経路
ユーザー kyo1kyo1
提出日時 2020-12-09 01:24:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 869 bytes
コンパイル時間 2,531 ms
コンパイル使用メモリ 212,904 KB
実行使用メモリ 269,992 KB
最終ジャッジ日時 2023-10-19 02:51:57
合計ジャッジ時間 15,028 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, M, K;
  cin >> N >> M >> K;
  vector<vector<pair<int, int>>> G(N);
  for (int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    G[a].emplace_back(make_pair(b, c));
    G[b].emplace_back(make_pair(a, c));
  }
  vector<int> D(K);
  for (auto &&e : D) {
    cin >> e;
  }
  vector<int> res;
  function<void(int, int)> dfs = [&](int u, int i) {
    if (i == K) {
      res.emplace_back(u);
      return;
    }
    for (auto [v, c] : G[u]) {
      if (D[i] == c) {
        dfs(v, i + 1);
      }
    }
  };
  for (int i = 0; i < N; i++) {
    dfs(i, 0);
  }
  sort(res.begin(), res.end());
  cout << res.size() << '\n';
  for (const auto &e : res) {
    cout << e + 1 << (&e == &res.back() ? '\n' : ' ');
  }
  return 0;
}
0