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

15262번 - Embedding Enumeration 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 512 MB169750.000%

문제

As you probably know, a tree is a graph consisting of n nodes and n − 1 undirected edges in which any two nodes are connected by exactly one path. In a labeled tree each node is labeled with a different integer between 1 and n. In general, it may be hard to visualize trees nicely, but some trees can be neatly embedded in rectangular grids.

Given a labeled tree G with n nodes, a 2 by n embedding of G is a mapping of nodes of G to the cells of a rectangular grid consisting of 2 rows and n columns such that:

  • Node 1 is mapped to the cell in the upper-left corner.
  • Nodes connected with an edge are mapped to neighboring grid cells (up, down, left or right).
  • No two nodes are mapped to the same cell.

Find the number of 2 by n embeddings of a given tree, modulo 109 + 7.

입력

The first line contains an integer n (1 ≤ n ≤ 300 000) — the number of nodes in G. The j-th of the following n − 1 lines contains two different integers aj and bj (1 ≤ aj, bj ≤ n) — the endpoints of the j-th edge.

출력

Output the number of 2 by n embeddings of the given tree, modulo 109 + 7.

제한

예제 입력 1

5
1 2
2 3
2 4
4 5

예제 출력 1

4

힌트

All 4 embeddings of the tree in the example input are given in the figure above.

출처

ICPC > Regionals > Europe > Central European Regional Contest > CERC 2017 E번

Contest > Open Cup > 2017/2018 Season > Stage 8: Grand Prix of Europe E번

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

출처

대학교 대회

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

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