結果

問題 No.92 逃走経路
ユーザー kyo1kyo1
提出日時 2020-12-09 01:21:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 949 bytes
コンパイル時間 4,817 ms
コンパイル使用メモリ 215,084 KB
実行使用メモリ 615,416 KB
最終ジャッジ日時 2023-10-19 02:48:33
合計ジャッジ時間 15,326 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
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;
  }
  queue<pair<int, int>> que;
  for (int i = 0; i < N; i++) {
    que.push(make_pair(i, 0));
  }
  vector<int> res;
  while (!que.empty()) {
    auto [u, i] = que.front();
    que.pop();
    if (i == K) {
      res.emplace_back(u);
      continue;
    }
    for (auto [v, c] : G[u]) {
      if (D[i] == c) {
        que.push(make_pair(v, i + 1));
      }
    }
  }
  sort(res.begin(), res.end());
  cout << res.size() << '\n';
  for (const auto &e : res) {
    cout << e + 1 << (&e == &res.back() ? '\n' : ' ');
  }
  return 0;
}
0