結果

問題 No.92 逃走経路
コンテスト
ユーザー kyo1
提出日時 2020-12-09 01:21:05
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
MLE  
実行時間 -
コード長 949 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,129 ms
コンパイル使用メモリ 224,964 KB
実行使用メモリ 838,644 KB
最終ジャッジ日時 2026-06-15 20:12:49
合計ジャッジ時間 14,727 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other MLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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