結果

問題 No.92 逃走経路
ユーザー DialBirdDialBird
提出日時 2017-04-02 10:30:09
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,063 bytes
コンパイル時間 1,219 ms
コンパイル使用メモリ 144,892 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-22 07:23:53
合計ジャッジ時間 2,306 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 5 ms
4,376 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 5 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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];
  fill(candidate, candidate+N, true);

  REP(i,K){
    int pay = d[i];
    bool new_candidate[N];

    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];
    }
  }

  cout << count(candidate, candidate+N, true) << endl;

  REP(i,N){
    if (candidate[i]) {
      prints(i+1);
    }
  }
  cout << endl;
}
0