結果

問題 No.1190 Points
ユーザー achapiachapi
提出日時 2023-04-23 11:31:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,185 bytes
コンパイル時間 2,001 ms
コンパイル使用メモリ 202,568 KB
実行使用メモリ 22,528 KB
最終ジャッジ日時 2024-04-25 08:44:27
合計ジャッジ時間 5,910 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 108 ms
9,984 KB
testcase_04 AC 70 ms
8,320 KB
testcase_05 AC 133 ms
9,984 KB
testcase_06 AC 86 ms
10,112 KB
testcase_07 AC 169 ms
12,800 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 135 ms
11,904 KB
testcase_14 AC 23 ms
7,040 KB
testcase_15 AC 247 ms
16,640 KB
testcase_16 AC 14 ms
5,376 KB
testcase_17 AC 194 ms
15,744 KB
testcase_18 AC 87 ms
8,448 KB
testcase_19 AC 16 ms
7,808 KB
testcase_20 AC 118 ms
11,008 KB
testcase_21 AC 30 ms
7,040 KB
testcase_22 AC 39 ms
8,704 KB
testcase_23 AC 225 ms
17,024 KB
testcase_24 AC 225 ms
16,896 KB
testcase_25 AC 85 ms
13,184 KB
testcase_26 AC 76 ms
9,856 KB
testcase_27 AC 88 ms
13,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int d[2][101010];
int d2[2][101010];

void dfs(Graph &g, int c, int v){
	c++;
	for (int i : g[v]){
		if (d[c % 2][i] == -1){
			d[c % 2][i] = c;
			dfs(g, c, i);
		}
	}
}

void dfs2(Graph &g, int c, int v){
	c++;
	for (int i : g[v]){
		if (d2[c % 2][i]  == -1){
			d2[c % 2][i] = c;
			dfs2(g, c, i);
		}
	}
}

int main() {
	int n, m, p;
	cin >> n >> m >> p;
	int S, G;
	cin >> S >> G;
	S--;
	G--;
	Graph g(n);
	for (int i = 0; i < m; i++){
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for (int i = 0; i < 2; i++){
		for (int j = 0; j < n; j++){
			d[i][j] = -1;
			d2[i][j] = -1;
		}
	}
	d[0][S] = 0;
	dfs(g, 0, S);
	d2[0][G] = 0;
	dfs2(g, 0, G);
	set<int> ans;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < 2; j++){
			for (int k = 0; k < 2; k++){
				if (d[j][i] == -1 or d2[k][i] == -1){
					continue;
				}
				int c = p - d[j][i] - d2[k][i];
				if (c >= 0 and c % 2 == 0){
					ans.insert(i);
				}
			}
		}
	}
	if (ans.empty()){
		cout << -1 << endl;
		return 0;
	}
	cout << ans.size() << endl;
	for (int i : ans){
		cout << i + 1 << endl;
	}
}
0