結果

問題 No.92 逃走経路
ユーザー DialBirdDialBird
提出日時 2017-03-10 07:01:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 24 ms / 5,000 ms
コード長 916 bytes
コンパイル時間 1,346 ms
コンパイル使用メモリ 161,864 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 12:57:12
合計ジャッジ時間 2,667 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,first,last) for (int i=first;i<last;++i)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)

int N,M,K;

int main(){
  cin >> N >> M >> K;
  vector<map<int, vector<int>>> town_info(N+1);

  REP(i,0,M){
    int a,b,c;
    cin >> a >> b >> c;
    town_info[a][c].push_back(b);
    town_info[b][c].push_back(a);
  }

  vector<int> d_list(K);
  REP(i,0,K){
    cin >> d_list[i];
  }

  set<int> candidate_towns;
  REP(i,0,N){
    candidate_towns.insert(i + 1);
  }

  for (int d: d_list) {
    set<int> rest_towns;
    for (int c: candidate_towns) {
      if (town_info[c][d].size() != 0) {
        for (int t: town_info[c][d]) {
          rest_towns.insert(t);
        }
      }
    }
    candidate_towns = rest_towns;
  }

  cout << candidate_towns.size() << endl;
  for (int c: candidate_towns) {
    cout << c << " ";
  }
  cout << endl;
}
0