結果

問題 No.1190 Points
ユーザー uzzyuzzy
提出日時 2020-08-22 16:41:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 2,038 bytes
コンパイル時間 2,619 ms
コンパイル使用メモリ 194,584 KB
実行使用メモリ 22,392 KB
最終ジャッジ日時 2024-04-27 03:25:29
合計ジャッジ時間 6,862 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,568 KB
testcase_01 AC 4 ms
10,392 KB
testcase_02 AC 3 ms
9,696 KB
testcase_03 AC 90 ms
18,716 KB
testcase_04 AC 72 ms
18,016 KB
testcase_05 AC 74 ms
17,124 KB
testcase_06 AC 120 ms
20,684 KB
testcase_07 AC 132 ms
21,432 KB
testcase_08 AC 152 ms
21,220 KB
testcase_09 AC 149 ms
21,944 KB
testcase_10 AC 157 ms
21,196 KB
testcase_11 AC 103 ms
19,100 KB
testcase_12 AC 154 ms
21,352 KB
testcase_13 AC 102 ms
18,252 KB
testcase_14 AC 20 ms
13,664 KB
testcase_15 AC 188 ms
22,244 KB
testcase_16 AC 17 ms
11,876 KB
testcase_17 AC 170 ms
21,160 KB
testcase_18 AC 70 ms
18,020 KB
testcase_19 AC 13 ms
13,032 KB
testcase_20 AC 89 ms
19,388 KB
testcase_21 AC 36 ms
14,436 KB
testcase_22 AC 34 ms
16,316 KB
testcase_23 AC 195 ms
22,392 KB
testcase_24 AC 190 ms
22,380 KB
testcase_25 AC 165 ms
21,872 KB
testcase_26 AC 74 ms
21,476 KB
testcase_27 AC 140 ms
21,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N, M, P;
	cin >> N >> M >> P;
	int S, G;
	cin >> S >> G;

#define PT pair<ll, int>
	vector<PT> E[200001];

	rep(i, M) {
		int u, v;
		cin >> u >> v;
		E[u * 2].pb({ 1, v * 2 + 1 });
		E[u * 2 + 1].pb({ 1, v * 2 });
		E[v * 2].pb({ 1, u * 2 + 1 });
		E[v * 2 + 1].pb({ 1, u * 2 });
	}

	ll DS[200001], DG[200001];
	rep1(i, N * 2) DS[i + 1] = 1e18;
	rep1(i, N * 2) DG[i + 1] = 1e18;

	priority_queue<PT, vector<PT>, greater<PT>> que;
	DS[S * 2] = 0;
	que.push(mp(0, S * 2));
	while (que.size()) {
		PT p = que.top();
		que.pop();
		int i = p.second;
		if (DS[i] != p.first) continue;
		for (PT p2 : E[i]) {
			int j = p2.second;
			ll d = DS[i] + p2.first;
			if (DS[j] > d) {
				DS[j] = d;
				que.push(mp(d, j));
			}
		}
	}
	DG[G * 2] = 0;
	que.push(mp(0, G * 2));
	while (que.size()) {
		PT p = que.top();
		que.pop();
		int i = p.second;
		if (DG[i] != p.first) continue;
		for (PT p2 : E[i]) {
			int j = p2.second;
			ll d = DG[i] + p2.first;
			if (DG[j] > d) {
				DG[j] = d;
				que.push(mp(d, j));
			}
		}
	}

	vector<int> kotae;
	rep1(i, N) {
		if (P % 2) {
			ll tmp = min(DS[i * 2] + DG[i * 2 + 1], DS[i * 2 + 1] + DG[i * 2]);
			if (tmp <= P) {
				kotae.pb(i);
			}
		}
		else {
			ll tmp = min(DS[i * 2] + DG[i * 2], DS[i * 2 + 1] + DG[i * 2 + 1]);
			if (tmp <= P) {
				kotae.pb(i);
			}
		}
	}

	int kazu = kotae.size();
	if (kazu == 0) co(-1);
	else {

		co(kotae.size());
		rep(i, kotae.size()) co(kotae[i]);
	}

	Would you please return 0;
}
0