結果

問題 No.92 逃走経路
ユーザー m1025o1184tm1025o1184t
提出日時 2019-12-28 20:33:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 854 bytes
コンパイル時間 1,782 ms
コンパイル使用メモリ 168,320 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 16:59:43
合計ジャッジ時間 2,906 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int p[1010][110];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	vector<int> a(1000), b(1000), c(1000), d(1000);
	rep(i, m) cin >> a[i] >> b[i] >> c[i];
	rep(i, k) cin >> d[i];


	for (int i = 0; i < m; ++i) {
		if (d[0] == c[i]) {
			p[0][a[i]] = 1;
			p[0][b[i]] = 1;
		}
	}

	for (int i = 1; i < k; ++i) {
		for (int j = 0; j < m; ++j) {
			if (d[i] == c[j]) {
				if (p[i - 1][a[j]]) p[i][b[j]] = 1;
				if (p[i - 1][b[j]]) p[i][a[j]] = 1;
			}
		}
	}

    ll ans = accumulate(p[k - 1], p[k - 1] + 100, 0);
	dunk(ans);

	for (int i = 1; i <= 100; ++i) {
		if (p[k - 1][i]) cout << i << ' ';
	}
	cout << endl;

	return 0;
}
0