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

31680번 - Lepeze 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB115545.455%

문제

Little Fran received a wooden frame in the shape of a regular polygon as a gift. As polygon has $n$ vertices, he also received $\frac{n(n-3)}{2}$ wooden sticks that match each possible diagonal. Vertices of the polygon are labelled with integers from 1ドル$ to $n$ in counterclockwise order. In the beginning, Fran arranged $n - 3$ sticks inside the frame in such a way that every stick touches two non-neighboring vertive of the frame, and no two sticks cross each other. In other words, he made a triangulation. As that was not interesting enough for him, he decided to play with this configuration by applying a particular operation that consists of two steps:

  1. Remove a stick.
  2. Add a new stick in such a way that we obtain a new triangulation.

We characterize the operation with an ordered pair of unordered pairs $((a, b),(c, d))$ which signifies that little Fran removed a stick touching vertices $a$ and $b,ドル and added a stick touching vertices $c$ and $d$.

Fran loves hand fans so, while doing these operations, he sometimes asks himself: “How many operations is needed to transform this triangulation into a “fan” triangulation in vertex $x,ドル and, in how many ways is this achievable?”.

Since he is busy doing operations and having fun, he asks for your help!

“Fan” triangulation in vertex $x$ is a triangulation where all diagonals have a common endpoint, namely vertex $x$.

Let the number of needed operations be $m$. Let $f_1, f_2, \dots , f_m$ be a sequence of operations that, when applied in given order, achieves wanted triangulation, thus representing one way of getting there. Let $s_1, s_2, \dots , s_m$ be another such sequence. Two sequences are distinct if there exists an index $i$ such that $f_i \ne s_i$ .

As the number of such sequences can be huge, little Fran is only interested in its remainder modulo 10ドル^9 + 7$.

입력

In the first line are integers $n$ and $q$ (4ドル ≤ n ≤ 2 \cdot 10^5,ドル 1ドル ≤ q ≤ 2 \cdot 10^5$), the number of vertices and the number of events.

In each of the next $n - 3$ lines there are integers $x_i,ドル $y_i$ (1ドル ≤ x_i , y_i ≤ n$), the labels of vertices that the $i$-th stick touches.

In each of the next $q$ lines there is the integer $t_i$ (1ドル ≤ t_i ≤ 2$) that represents the type of event.

If $t_i = 1,ドル it is followed by 4ドル$ integers $a_i,ドル $b_i,ドル $c_i,ドル $d_i$ (1ドル ≤ a_i , b_i , c_i , d_i ≤ n$) that signify an operation $((a_i , b_i),(c_i , d_i))$ is being made at that moment. It is guaranteed that given operation can be realized.

If $t_i = 2,ドル it is followed by an integer $x_i$ (1ドル ≤ x_i ≤ n$), which means that little Fran is interested in data for the “fan” triangulation at vertex $x_i$ in relation to the current triangulation.

출력

For every event of type 2ドル,ドル in order they came in input, output two integers, minimal number of operations needed and number of ways to get to the target triangulation using minimal number of operations.

제한

서브태스크

번호배점제한
112

$n ≤ 9,ドル $q ≤ 1,円 000$

216

$x_i = 1,ドル $y_i = i + 2$ for all $i = 1, \dots , n - 3$ and there are no events of type 1ドル$.

330

$q = 1$

412

$n, q ≤ 1,円 000$

540

No additional constraints.

예제 입력 1

4 3
1 3
2 1
1 1 3 2 4
2 1

예제 출력 1

0 1
1 1

Starting triangulation is already a “fan” triangulation in vertex 1ドル,ドル so little Fran must do no operations, which there is one way of doing so. After executing a given operation, there is now only one way to get it to the previous state and that is by applying operation $((2, 4),(1, 3))$.

예제 입력 2

5 4
1 3
3 5
2 1
2 2
1 1 3 2 5
2 2

예제 출력 2

1 1
2 1
1 1

Only sequence of operations for the first query: $((3, 5),(1, 4))$.

Only sequence of operations for the second query: $((1, 3),(2, 5)),((3, 5),(2, 4))$.

Only sequence of operations for the third query: $((3, 5),(2, 5))$.

예제 입력 3

9 3
1 5
1 7
2 4
2 5
5 7
7 9
2 1
1 2 5 1 4
2 1

예제 출력 3

4 12
3 6

힌트

출처

Contest > Croatian Open Competition in Informatics > COCI 2023/2024 > Contest #4 3번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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