Logo
(追記) (追記ここまで)

22929번 - Special Cycle 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
7 초 2048 MB (추가 메모리 없음)56101022.222%

문제

You are given a simple undirected graph with no self-loops or multiple edges. Some of the edges are marked as Special.

Your task is to find a simple cycle where, for each Special edge, that edge either belongs to the cycle or neither of its endpoints touch the cycle. The cycle is not allowed to repeat vertices. Output any solution, or report that none exist.

입력

The first line of input contains three integers $n$ (2ドル \le n \le 150$), $m$ (1ドル \le m \le \frac{n \cdot (n-1)}{2}$) and $k$ (1ドル \le k \le m$), where $n$ is the number of nodes in the graph, $m$ is the number of edges, and $k$ is the number of edges that are Special. The nodes are numbered 1ドル$ through $n$.

Each of the next $m$ lines contains two integers $a$ and $b$ (1ドル \le a < b \le n$), denoting an undirected edge between nodes $a$ and $b$. All edges are distinct. The first $k$ edges are the Special edges.

출력

Output an integer denoting the length of the found cycle on one line. On subsequent lines, output the vertices of the cycle in order around the cycle, one per line. If no such cycle exists, simply output $-1$.

제한

예제 입력 1

8 10 3
1 2
4 5
7 8
2 3
3 4
1 4
5 6
6 7
5 8
3 8

예제 출력 1

8
1
4
5
6
7
8
3
2

예제 입력 2

4 6 3
1 2
1 3
1 4
2 3
3 4
2 4

예제 출력 2

-1

힌트

출처

ICPC > Regionals > North America > North America Championship > North America Championship 2021 H번

Camp > Petrozavodsk Programming Camp > Summer 2021 > Day 2: The American Contest H번

  • 문제를 만든 사람: Lewin Gan
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /