結果

問題 No.92 逃走経路
ユーザー koba-e964koba-e964
提出日時 2015-06-10 22:47:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 1,368 bytes
コンパイル時間 684 ms
コンパイル使用メモリ 96,436 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 20:38:48
合計ジャッジ時間 1,651 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,376 KB
testcase_01 AC 1 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 2 ms
4,380 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 3 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 4 ms
4,376 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;

const int N = 101;
map<int, bitset<N> > edge[N];
int d[1010];
int main(void){
  int n, m, k;
  cin >> n >> m >> k;
  REP(i, 0, m) {
    int a,b,c;
    cin >> a >> b >> c;
    a--, b--;
    if (edge[a].count(c) == 0) {
      edge[a][c] = bitset<N>();
    }
    if (edge[b].count(c) == 0) {
      edge[b][c] = bitset<N>();
    }
    edge[a][c].set(b);
    edge[b][c].set(a);
  }
  REP(i, 0, k) {
    cin >> d[i];
  }
  bitset<N> bs;
  bs.flip();
  for (int i = 0; i < k; ++i) {
    bitset<N> sub;
    REP(j, 0, n) {
      if (bs[j]) {
	sub |= edge[j][d[i]];
      }
    }
    bs = sub;
  }
  cout << bs.count() << endl;
  int c = 0;
  REP (i, 0, bs.size()) {
    if (bs[i]) {
      if (c) {
	cout << " ";
      }
      cout << i + 1;
      c = 1;
    }
  }
  cout << endl;
}
0