RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00614

Šarenlist

Unrated 레이팅 미적용
난이도
1s
시간 제한
512MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Warm summer night. Vito and his friend, Karlo, are lying in a forest clearing
and watching the stars. Suddenly, Vito exclaims “Karlo, look! The trees around
us are changing colors!” “Wooow so colorful” said Karlo, amazed. Indeed, the
tree branches in the forest started to change colors.
Fascinated by the colorful trees, Vito and Karlo noticed a couple of facts about
them. Each of the trees they are looking at can be represented as a tree graph,
i.e. an undirected graph in which there exists a unique path between each pair
of nodes. The trees they are looking at have the property that each edge of
the tree is colored in one of \(k\) different colors. Some of the paths on the tree
are colorful, meaning that such a path contains edges of at least two different
colors.
Morning has arrived and the tree magic is now lost. In order to relive this experience, Vito and Karlo ask
you to solve the following problem. Given a tree and \(m\) pairs of nodes on the tree, determine the number
of different colorings of the tree edges so that each of the \(m\) paths determined by the \(m\) pairs of nodes is
colorful. Since this number can be very large, output it modulo \(10^{9} + 7\).

제약

Subtask 1 (10 points): \(m = 1\)

Subtask 2 (15 points): \(m = 2\)

Subtask 3 (10 points): Each tree edge belongs to at most one of the \(m\) given paths.

Subtask 4 (10 points): \(1 \le n \le 15\), \(k = 2\)

Subtask 5 (65 points): No additional constraints.

입력 형식

The first line contains three positive integers \(n\), \(m\) and \(k\) (\(3 \le n \le 60\), \(1 \le m \le 15\), \(2 \le k \le 10^{9}\)), the
number of nodes in the tree, the number of path required to be colorful and the number of possible colors
for the tree branches, respectively.
The \(i-th\) of the next \(n - 1\) lines contains a pair of positive integers \(a_{i}\) and \(b_{i}\) (\(1 \le a_{i}\), \(b_{i} \le n\)), representing
an edge of the tree.
The \(j-th\) of the next \(m\) lines contains a pair of positive integers \(c_{j}\) and \(d_{j}\) (\(1 \le c_{j}\), \(d_{j} \le n\)), the labels of the
endpoints of the paths which are required to be colorful. The nodes \(c@@RISE_MATH_BLOCK_0@@j\) are not neighbouring.

출력 형식

In the only line print the number of ways to color the tree edges so that each of the \(m\) given paths is
colorful, modulo \(10^{9} + 7\).

서브태스크
서브태스크점수설명

1

10점

\(m = 1\)

2

15점

\(m = 2\)

3

10점

Each tree edge belongs to at most one of the \(m\) given paths.

4

10점

\(1 \le n \le 15\), \(k = 2\)

5

65점

No additional constraints.

예제 1
입력
3 1 2
1 2
2 3
1 3
출력
2
예제 2
입력
4 3 2
1 2
2 3
4 2
1 4
1 3
4 3
출력
0
예제 3
입력
4 3 3
1 2
2 3
4 2
1 4
1 3
4 3
출력
6
설명

Clarification of the first example:
The tree consists of only two edges, both part of a colorful path between the nodes 1 and 3. So, the two
edges must have a different color. One such coloring is obtained by coloring the edge 1-2 in color 1, and
2-3 in color 2, while the other is obtained by switching these color so that 1-2 has color 2, and 2-3 has
color 1.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2021/2022 Contest 4

평가 및 의견

Šarenlist

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Šarenlist

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8