結果

問題 No.92 逃走経路
ユーザー Mcpu3Mcpu3
提出日時 2020-02-19 15:31:22
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 991 bytes
コンパイル時間 973 ms
コンパイル使用メモリ 86,592 KB
実行使用メモリ 816,528 KB
最終ジャッジ日時 2024-04-16 21:32:21
合計ジャッジ時間 6,323 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 <algorithm>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int N, M, K, a, b;
	cin >> N >> M >> K;
	vector<vector<pair<int, long>>> e(N);
	for (int i = 0; i < M; i++) {
		long c;
		cin >> a >> b >> c;
		e[a - 1].emplace_back(b - 1, c);
		e[b - 1].emplace_back(a - 1, c);
	}
	vector<long> d(K);
	for (long& i : d) cin >> i;
	reverse(d.begin(), d.end());
	vector<int> ans;
	for (int i = 0; i < N; i++) {
		queue<pair<int, vector<long>::iterator>> f;
		for (pair<int, long>& j : e[i]) {
			if (d.front() == j.second) f.emplace(j.first, d.begin() + 1);
		}
		while (!f.empty()) {
			if (f.front().second == d.end()) {
				ans.push_back(i + 1);
				break;
			}
			for (pair<int, long>& j : e[f.front().first]) {
				if (*f.front().second == j.second) f.emplace(j.first, f.front().second + 1);
			}
			f.pop();
		}
	}
	cout << ans.size() << endl;
	for (int& i : ans) cout << i << ' ';
}
0