結果

問題 No.92 逃走経路
ユーザー CleyLCleyL
提出日時 2022-09-28 08:34:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 1,029 bytes
コンパイル時間 1,189 ms
コンパイル使用メモリ 106,896 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-24 04:15:41
合計ジャッジ時間 3,963 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
struct d{
  int a,b,c;
};
int main(){
  int n,m,k;cin>>n>>m>>k;
  vector<d> A(m);
  vector<int> B(m);
  for(int i = 0; m > i; i++){
    cin>>A[i].a>>A[i].b>>A[i].c;
    B[i] = A[i].c;
  }
  sort(B.begin(),B.end());
  B.erase(unique(B.begin(),B.end()),B.end());
  map<int,int> C;
  for(int i = 0; B.size() > i; i++){
    C[B[i]] = i;
  }
  vector<pair<int,int>> D[B.size()];
  for(int i = 0; m > i; i++){
    D[C[A[i].c]].push_back({A[i].a,A[i].b});
    D[C[A[i].c]].push_back({A[i].b,A[i].a});
  }
  set<int> X;
  for(int i = 0; k > i; i++){
    int x;cin>>x;
    set<int> Y;
    for(int j = 0; (int)D[C[x]].size() > j; j++){
      if(!i || X.count(D[C[x]][j].first)){
        Y.insert(D[C[x]][j].second);
      }
    }
    X = Y;
  }
  vector<int> ans;
  for(auto z: X){
    ans.push_back(z);
  }
  cout << ans.size() << endl;
  for(int i = 0; ans.size() > i; i++){
    cout << ans[i] << " \n"[i+1==ans.size()];
  }
}
0