結果

問題 No.92 逃走経路
ユーザー DialBirdDialBird
提出日時 2017-04-02 09:58:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 31 ms / 5,000 ms
コード長 952 bytes
コンパイル時間 1,733 ms
コンパイル使用メモリ 159,532 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 07:23:48
合計ジャッジ時間 3,165 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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_K = 1000;
map<int, vector<int>> G[MAX_N];
int d[MAX_K];

int main(){
  int N, M, K;
  cin >> N >> M >> K;
  REP(i,M){
    // aは0からN-1にする
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    G[a][c].push_back(b);
    G[b][c].push_back(a);
  }

  REP(i,K){ cin >> d[i]; }

  set<int> candidate;
  REP(i,N) candidate.insert(i);

  REP(i,K){
    int pay = d[i];
    set<int> new_candidate;
    for (auto c: candidate){
      if (!G[c][pay].empty()) {
        for (auto t: G[c][pay]){
          new_candidate.insert(t);
        }
      }
    }
    candidate = new_candidate;
  }

  printn(candidate.size());
  for(auto c: candidate) {
    prints(c+1);
  }
  cout << endl;
}
0