結果

問題 No.92 逃走経路
ユーザー 🍡yurahuna🍡yurahuna
提出日時 2016-02-26 13:24:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,476 bytes
コンパイル時間 2,055 ms
コンパイル使用メモリ 80,752 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 20:16:43
合計ジャッジ時間 1,497 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)

#define PI 3.1415926535

typedef long long ll;
//typedef pair<int, int> P;
//typedef complex<double> C;

struct edge { int to, cost; };

const int MAX_N = 100;
const int MAX_K = 1000;

int N, M, K;
vector<edge> G[MAX_N];
int d[MAX_K];

void input() {
	cin >> N >> M >> K;
	REP(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		G[a].pb((edge){b, c});
		G[b].pb((edge){a, c});
	}
	REP(i, K) cin >> d[i];
}

void solve() {
	bool v1[N];
	bool v2[N];
	REP(i, N) {
		v1[i] = false;
		v2[i] = false;
	}

	// d_0の両端を最初の候補に入れる
	REP(i, N) {
		for (auto e: G[i]) {
			if (e.cost == d[0]) {
				v1[i] = true;
				v1[e.to] = true;
			}
		}
	}

	FOR(k, 1, K) {
		REP(i, N) {
			for (auto e: G[i]) {
				if (v1[i] && e.cost == d[k]) {
					v2[e.to] = true;
				}
			}
		}
		REP(i, N) v1[i] = v2[i];
	}

	vector<int> ans;
	REP(i, N) {
		if (v1[i]) {
			ans.pb(i + 1);
		}
	}

	cout << ans.size() << endl;
	REP(i, ans.size()) {
		cout << ans[i] << ' ';
	}
	cout << endl;
}

int main() {
    input();
    solve();
    return 0;
}
0