結果

問題 No.92 逃走経路
ユーザー DialBirdDialBird
提出日時 2017-03-10 06:59:03
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 928 bytes
コンパイル時間 1,786 ms
コンパイル使用メモリ 158,288 KB
実行使用メモリ 814,560 KB
最終ジャッジ日時 2023-09-06 12:57:32
合計ジャッジ時間 13,800 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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

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

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

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