Zbunjenost

시간 제한5초메모리 제한1024 MB

요약
볼록 다각형의 삼각분할이 주어질 때 그래프에 있는 단순 사이클의 개수를 10^9+7로 나눈 나머지를 구한다.
난이도

어려움10점 중 8점

유형
그래프, 동적 계획법, 조합론, 트리
정답자
아직 제출이 없습니다

문제

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 NN interesting locations numbered from 11 to NN connected by 2N−32N - 3 streets. Locations 1,2,…,N1, 2, \dots , N are connected in that order to form a convex polygon with NN sides. Remaining N−3N - 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_mV\_1, V\_2, \dots , V\_m such that V_iV\_i is connected via street with location V_i+1V\_{i+1} for every i=1,2,…,m−1i = 1, 2, \dots , m - 1 and that location V_mV\_m is connected with V_1V\_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)(1, 2, 3, 4) is equivalent to the walk (2,3,4,1)(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 NN (1≤N≤2⋅1051 ≤ N ≤ 2 \cdot 10^5), number of interesting locations.

In the next N−3N - 3 lines are integers X_iX\_i, Y_iY\_i (1≤X_i,Y_i≤N1 ≤ X\_i , Y\_i ≤ N), labels of locations connected by ii-th street.

출력

In the first and only line output the confusion of the given city modulo 109+710^9 + 7.

예제3

  1. 예제 1

    입력
    4
    1 3
    
    예상 출력
    3
    
  2. 예제 2

    입력
    5
    1 3
    3 5
    
    예상 출력
    6
    
  3. 예제 3

    입력
    6
    2 4
    4 6
    6 2
    
    예상 출력
    11