시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 173 15 14 20.290%

문제

T는 루트가 있는 트리이다. S는 T의 완벽한 복사본이다. 자 이제 T와 S를 합친다. 루트를 제외한 모든 단말 노드 (leaf node)를 합치면 된다. 이 그래프는 거울대칭트리 그래프이다.

임의의 무방향 연결 그래프가 주어졌을 때, 이 그래프가 거울대칭트리 그래프인지 아닌지 판별하는 프로그램을 작성하시오.

입력

첫째 줄에 N과 M이 주어진다. N은 정점의 개수 M은 간선의 개수이다. 그래프의 정점은 1부터 N까지 번호가 매겨져 있다. 다음 M개의 줄에는 x와 y가 주어진다. (x ≠ y, 1 ≤ x, y ≤ N) x와 y는 하나의 간선이고, x와 y가 이어져 있는 것이다. 두 정점 사이에는 많아야 하나의 간선만 있을 수 있다. (3 ≤ N, M ≤ 100,000)

출력

첫째 줄에 그래프가 거울대칭트리 그래프이면 YES를 아니면 NO를 출력한다.

예제 입력 1

22 28
13 8
8 1
1 22
1 12
1 14
13 18
13 4
4 20
20 7
13 15
15 3
15 9
9 16
9 19
22 5
12 5
14 5
5 11
11 6
18 6
7 10
10 17
17 6
3 21
21 6
16 2
19 2
2 21

예제 출력 1

YES

힌트

W3sicHJvYmxlbV9pZCI6IjI0MzAiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWFjNzBcdWM2YjhcdWIzMDBcdWNlNmRcdWQyYjhcdWI5YWMgXHVhZGY4XHViNzk4XHVkNTA0IiwiZGVzY3JpcHRpb24iOiI8cD5UXHViMjk0IFx1YjhlOFx1ZDJiOFx1YWMwMCBcdWM3ODhcdWIyOTQgXHVkMmI4XHViOWFjXHVjNzc0XHViMmU0LiBTXHViMjk0IFRcdWM3NTggXHVjNjQ0XHViY2JkXHVkNTVjIFx1YmNmNVx1YzBhY1x1YmNmOFx1Yzc3NFx1YjJlNC4gXHVjNzkwIFx1Yzc3NFx1YzgxYyBUXHVjNjQwIFNcdWI5N2MgXHVkNTY5XHVjZTVjXHVi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gMSB0byBOLiBUaGUgZm9sbG93aW5nIE0gbGluZXMgZGVzY3JpYmUgdGhlIGVkZ2VzLiBFYWNoIHN1Y2ggbGluZSBjb250YWlucyB0d28gaW50ZWdlcnMgeCBhbmQgeSAoeCAmbmU7IHk7IDEgJmxlOyB4LCB5ICZsZTsgTiksIGRlc2NyaWJpbmcgb25lIGVkZ2UuIFRoZXJlIHdpbGwgYmUgYXQgbW9zdCBvbmUgZWRnZSBiZXR3ZWVuIGFueSBwYWlyIG9mIHZlcnRpY2VzLiZuYnNwOygzICZsZTsgTiwgTSAmbGU7IDEwMCwwMDApPFwvcD5cclxuIiwib3V0cHV0IjoiPHA+VGhlIFx1ZmIwMXJzdCBhbmQgb25seSBsaW5lIG9mIG91dHB1dCBzaG91bGQgY29udGFpbiB0aGUgc3RyaW5nIFlFUyBpZiB0aGUgZ3JhcGggRyBpcyBhIHRyZWUtbWlycm9yZWQgZ3JhcGgsIGFuZCBOTyBvdGhlcndpc2UuPFwvcD5cclxuIiwiaGludCI6IjxwPjxpbWcgYWx0PVwiXCIgc3JjPVwiXC9KdWRnZU9ubGluZVwvdXBsb2FkXC8yMDExMDhcL3RyZWUuSlBHXCIgc3R5bGU9XCJoZWlnaHQ6MjcycHg7IG9wYWNpdHk6MC45OyB3aWR0aDozMjhweFwiIFwvPjxcL3A+XHJcbiIsIm9yaWdpbmFsIjoiMSIsImh0bWxfdGl0bGUiOiIwIiwicHJvYmxlbV9sYW5nX3Rjb2RlIjoiRW5nbGlzaCJ9XQ==

출처

Olympiad > Baltic Olympiad in Informatics > BOI 2011 8번

  • 문제를 번역한 사람: baekjoon
  • 데이터를 추가한 사람: kareus