問題一覧 > 通常問題

No.1190 Points

レベル : / AI推定難易度 : 1200 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 123
作問者 : AndrewK / テスター : Rho
お気に入りにしたユーザー ProblemId : 4671 / 自分の提出
問題文最終更新日: 2020-08-22 11:45:32
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
技術室奥プログラミングコンテスト#5 Day1 (順位表) の他の問題:

Problem Statement

You are given an undirected graph with $N$ vertices and $M$ edges, containing no self-loops or multiple edges.
The $ i (1 \le i \le M)$-th edge connects vertex $u_i$ and vertex $v_i$.
When moving from vertex $S$ to vertex $G$ while traversing edges exactly $P$ times in total, find all vertices that may be passed through (including $S, G$).

The writer has confirmed that this problem can get AC using PyPy3, but it has not been confirmed whether AC is possible with Python3.
Please be very careful when submitting in Python.

Input

$N\ M\ P$
$S\ G$
$u_1\ v_1$
$u_2\ v_2$
$\vdots$
$u_M\ v_M$

All inputs are integers.
$2 \le N \le 10^5$
$1 \le M \le min(10^5,N \times (N-1)/2)$
$1 \le P \le 10^9$
$1 \le S, G \le N$
$S \neq G$
$1 \le u_i , v_i \le N$
$ u_i \neq v_i $
When $ i \neq j $, $ (u_i, v_i) \neq (u_j, v_j) $ and $ (u_i, v_i) \neq (v_j, u_j) $

Output

First, output the number $K$ of vertices that may be passed through, and then, on the following $K$ lines, output the vertices that may be passed through in ascending order.
However, if no movement satisfying the condition is possible, output $-1$.
Print a newline at the end.

Sample

Sample 1
Input
6 5 3
1 4
1 2
1 3
1 4
2 5
3 6
Output
4
1
2
3
4

There are $(1→2→1→4),(1→3→1→4),(1→4→1→4)$, a total of 3 ways to go from point 1 to point 4 while traversing edges 3 times.

Sample 2
Input
4 3 4
1 4
1 2
2 3
3 4
Output
-1

Sample 3
Input
10 9 5
1 10
7 2
4 9
5 3
1 9
2 9
8 7
8 5
6 4
10 2
Output
6
1
2
4
7
9
10

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。