結果

問題 No.1190 Points
ユーザー tkmst201tkmst201
提出日時 2021-02-11 09:57:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,542 bytes
コンパイル時間 2,161 ms
コンパイル使用メモリ 211,092 KB
実行使用メモリ 20,344 KB
最終ジャッジ日時 2023-09-24 22:59:09
合計ジャッジ時間 8,016 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 62 ms
15,344 KB
testcase_04 AC 51 ms
14,072 KB
testcase_05 AC 48 ms
12,908 KB
testcase_06 WA -
testcase_07 AC 98 ms
19,740 KB
testcase_08 AC 103 ms
20,056 KB
testcase_09 AC 98 ms
18,248 KB
testcase_10 AC 104 ms
19,972 KB
testcase_11 AC 64 ms
14,276 KB
testcase_12 AC 102 ms
19,608 KB
testcase_13 AC 54 ms
12,080 KB
testcase_14 AC 25 ms
13,208 KB
testcase_15 AC 102 ms
19,412 KB
testcase_16 AC 13 ms
6,260 KB
testcase_17 AC 89 ms
18,864 KB
testcase_18 AC 39 ms
7,724 KB
testcase_19 AC 27 ms
16,628 KB
testcase_20 AC 50 ms
10,012 KB
testcase_21 AC 28 ms
10,820 KB
testcase_22 AC 39 ms
17,084 KB
testcase_23 AC 110 ms
20,344 KB
testcase_24 AC 104 ms
19,932 KB
testcase_25 AC 72 ms
19,536 KB
testcase_26 AC 57 ms
19,160 KB
testcase_27 AC 78 ms
19,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//

int main() {
	int N, M, P, S, G;
	cin >> N >> M >> P >> S >> G;
	--S; --G;
	
	vector<vector<int>> g(N);
	REP(i, M) {
		int u, v;
		scanf("%d %d", &u, &v);
		--u; --v;
		g[u].emplace_back(v);
		g[v].emplace_back(u);
	}
	
	auto solve = [&](int s) {
		vector dist(N, vector(2, INF)); // [i][j] := j=0(even), j=1(odd)
		queue<pii> que; // u, d
		que.emplace(s, 0);
		while (!que.empty()) {
			auto [u, d] = que.front();
			que.pop();
			for (int v : g[u]) if (chmin(dist[v][(d + 1) & 1], d + 1)) que.emplace(v, d + 1);
		}
		return dist;
	};
	
	auto d1 = solve(S), d2 = solve(G);
	
	vector<int> ans;
	REP(i, N) {
		bool ok = false;
		REP(j, 2) REP(k, 2) {
			if (d1[i][j] == INF || d2[i][k] == INF) continue;
			const int d = d1[i][j] + d2[i][k];
			ok |= d <= P && (P - d) % 2 == 0;
		}
		if (ok) ans.emplace_back(i);
	}
	
	if (ans.empty()) puts("-1");
	else {
		cout << ans.size() << endl;
		for (int i : ans) printf("%d\n", i + 1);
	}
}
0