結果

問題 No.92 逃走経路
ユーザー 37kt_37kt_
提出日時 2016-03-03 18:41:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 694 bytes
コンパイル時間 1,330 ms
コンパイル使用メモリ 172,312 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 19:41:20
合計ジャッジ時間 2,281 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int n, m, k;
map<int, vector<pair<int, int>>> g;
bool f[1010][100];

int main()
{
  cin >> n >> m >> k;
  for (int i = 0; i < m; i++){
    int a, b, c;
    cin >> a >> b >> c, a--, b--;
    g[c].emplace_back(a, b);
    g[c].emplace_back(b, a);
  }

  for (int i = 0; i < n; i++) f[0][i] = 1;
  for (int i = 0; i < k; i++){
    int d;
    cin >> d;
    for (auto e : g[d]){
      f[i + 1][e.second] |= f[i][e.first];
    }
  }
  
  vector<int> res;
  for (int i = 0; i < n; i++){
    if (f[k][i]) res.push_back(i + 1);
  }
  cout << res.size() << endl;
  for (int i = 0; i < res.size(); i++){
    cout << res[i] << "\n "[i + 1 < res.size()];
  }
}
0