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

Zbunjenost

설명

Mr. Malnar decided to spend his summer traveling around the world by flying
randomly. After some time, he found himself in an unknown country’s capital
where streets reminded him of a triangulation! More precisely, the city consists
of \(N\) interesting locations numbered from 1 to \(N\) connected by 2N - 3 streets.
Locations 1, 2, . . ., \(N\) are connected in that order to form a convex polygon with
\(N\) sides. Remaining \(N - 3\) streets connect locations in such a way that no two
streets cross, except maybe at their ends.
While walking the streets of this country’s capital Mr. Malnar found himself at the location where he
started from without visiting any location more than once. A bit confused he came to the realization
that this is completely normal and came up with a measure of confusion as the number of simple closed
loops. Simple closed walk is a sequence of locations \(V_{1}\), \(V_{2}\), . . ., \(V_{m}\) such that \(V_{i}\) is connected via street
with location \(V_{\)i+1\(}\) for every \(i = 1\), 2, . . . , \(m - 1\) and that location \(V_{m}\) is connected with \(V_{1}\). Two walks are
equivalent if one can be obtained by a cyclic rotation of the other, or by reversing the other. For example,
walk (1, 2, 3, 4) is equivalent to the walk (2, 3, 4, 1). Simple closed loop is a set of equivalent walks. Mr.
Malnar now asks for your help in calculating the confusion of this city!

제약
입력 형식

In the first line is an integer \(N\) (\(1 \le N \le 2 \cdot 10^{5}\)), number of interesting locations.
In the next \(N - 3\) lines are integers \(X_{i}\), \(Y_{i}\) (\(1 \le X_{i}\), \(Y_{i} \le N\)), labels of locations connected by \(i\)-th street.

출력 형식

In the first and only line output the confusion of the given city modulo \(10^{9} + 7\).

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

1

13점

\(N \le 15\)

2

18점

\(N \le 300\)

3

34점

\(N \le 2000\)

4

15점

Locations 1 and \(k\) are connected for all \(k = 3\), 4, . . . , \(N - 1\).

5

40점

No additional constraints.

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

Clarification of the first example:
On the sketch, each loop is colored in a different color.
Clarification of the second example:
Walks that represent loops are: (1, 2, 3), (1, 3, 5), (3, 4, 5), (1, 2, 3, 5), (1, 3, 4, 5), (1, 2, 3, 4, 5).
Clarification of the third example:
Walks that represent loops are: (1, 2, 6), (2, 3, 4), (4, 5, 6), (2, 4, 6), (1, 2, 4, 6), (2, 3, 4, 6), (2, 4, 5, 6),
(1, 2, 3, 4, 6), (2, 3, 4, 5, 6), (1, 2, 4, 5, 6), (1, 2, 3, 4, 5, 6).

문제 정보

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

출처 COCI 2024/2025 Contest 1

평가 및 의견

Zbunjenost

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

Log in to rate problems.

개별 의견

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

풀이 제출

Zbunjenost

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