結果

問題 No.92 逃走経路
ユーザー kk
提出日時 2020-07-22 18:48:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 932 bytes
コンパイル時間 2,152 ms
コンパイル使用メモリ 204,832 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-03 18:45:59
合計ジャッジ時間 3,388 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

const double PI = acos(-1);

int n, m, k;
vector<pair<int, int> > edges[100];
bool dp[1001][100];

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin >> n >> m >> k;
  REP (i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    edges[a].emplace_back(b, c);
    edges[b].emplace_back(a, c);
  }

  vector<int> d(k);
  REP (i, k) cin >> d[i];
  
  REP (i, n) dp[0][i] = true;
  REP (i, k) REP (j, n) {
    if (!dp[i][j]) continue;
    for (auto &pr: edges[j]) {
      if (pr.second == d[i]) {
        dp[i+1][pr.first] = true;
      }
    }
  }
  vector<int> ret;
  REP (i, n) if (dp[k][i]) ret.push_back(i+1);

  cout << ret.size() << endl;
  for (int x: ret)
    cout << x << " ";
  cout << endl;
  
  return 0;
}
0