結果

問題 No.92 逃走経路
ユーザー utouto97utouto97
提出日時 2019-03-08 14:04:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,224 bytes
コンパイル時間 2,257 ms
コンパイル使用メモリ 155,388 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-05 19:38:43
合計ジャッジ時間 3,432 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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];

  set<int> from, to;
  rep(i, n) from.insert(i);

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

  cout << from.size() << endl;
  for(auto i : from){
    cout << i << " ";
  }
  cout << endl;

  return 0;
}
0