結果
| 問題 | 
                            No.92 逃走経路
                             | 
                    
| コンテスト | |
| ユーザー | 
                             a01sa01to
                         | 
                    
| 提出日時 | 2025-01-24 00:40:45 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 31 ms / 5,000 ms | 
| コード長 | 1,027 bytes | 
| コンパイル時間 | 3,962 ms | 
| コンパイル使用メモリ | 284,632 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2025-01-24 00:40:51 | 
| 合計ジャッジ時間 | 4,677 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 18 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector Graph(n, vector<pair<int, int>>(0));
  rep(_, m) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    Graph[a].push_back({ b, c });
    Graph[b].push_back({ a, c });
  }
  set<int> cand;
  rep(_, k) {
    int d;
    cin >> d;
    if (_ == 0) {
      rep(i, n) {
        bool ok = false;
        for (auto [__, cost] : Graph[i]) {
          if (cost == d) ok = true;
        }
        if (ok) cand.insert(i);
      }
    }
    else {
      set<int> nCand;
      for (int i : cand) {
        for (auto [j, cost] : Graph[i]) {
          if (cost == d) nCand.insert(j);
        }
      }
      swap(cand, nCand);
    }
  }
  cout << cand.size() << endl;
  for (auto x : cand) cout << x + 1 << ' ';
  cout << endl;
  return 0;
}
            
            
            
        
            
a01sa01to