結果
| 問題 | 
                            No.92 逃走経路
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2017-04-02 10:31:36 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 4 ms / 5,000 ms | 
| コード長 | 1,140 bytes | 
| コンパイル時間 | 1,302 ms | 
| コンパイル使用メモリ | 158,828 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-07 23:56:41 | 
| 合計ジャッジ時間 | 1,668 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 18 | 
ソースコード
#include <bits/stdc++.h>
 
using namespace std;
 
#define REP(i,last) for (int i=0;i<last;i++)
#define prints(str) cout << str << " ";
#define printn(str) cout << str << endl;
typedef pair<int, int> p_ii;
typedef long long ll;
const int MAX_N = 100;
const int MAX_M = 1000;
const int MAX_K = 1000;
struct root {
  int a, b, c;
};
root roots[MAX_M];
int d[MAX_K];
int main(){
  roots[0].a = 12;
  int N, M, K;
  cin >> N >> M >> K;
  REP(i,M){
    cin >> roots[i].a >> roots[i].b >> roots[i].c;
    --roots[i].a;
    --roots[i].b;
  }
  REP(i,K){ cin >> d[i]; }
  bool candidate[N];
  bool new_candidate[N];
  fill(candidate, candidate+N, true);
  fill(new_candidate, new_candidate+N, false);
  REP(i,K){
    int pay = d[i];
    REP(j,M){
      if (roots[j].c != pay) continue;
      new_candidate[roots[j].a] |= candidate[roots[j].b];
      new_candidate[roots[j].b] |= candidate[roots[j].a];
    }
    REP(i,N){
      candidate[i] = new_candidate[i];
      new_candidate[i] = false;
    }
  }
  cout << count(candidate, candidate+N, true) << endl;
  REP(i,N){
    if (candidate[i]) {
      prints(i+1);
    }
  }
  cout << endl;
}