結果

問題 No.92 逃走経路
ユーザー utouto97utouto97
提出日時 2019-03-08 13:49:10
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 1,244 bytes
コンパイル時間 2,142 ms
コンパイル使用メモリ 154,296 KB
実行使用メモリ 667,364 KB
最終ジャッジ日時 2023-09-05 19:38:27
合計ジャッジ時間 15,226 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

int main()
{
  int n, m, k;
  cin >> n >> m >> k;

  vector<pii> g[n];
  rep(i, m){
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    g[a].pb({b, c});
    g[b].pb({a, c});
  }

  vi d(k);
  rep(i, k) cin >> d[i];

  vi from, to;
  rep(i, n) from.pb(i);

  rep(i, k){
    for(auto f : from){
      for(auto e : g[f]){
        if(e.second == d[i]){
          to.pb(e.first);
        }
      }
    }
    from.swap(to);
    to.clear();
  }

  sort(all(from));
  cout << from.size() << endl;
  rep(i, from.size()){
    cout << from[i]+1 << " \n"[i == from.size()-1];
  }

  return 0;
}
0