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

Lepeze

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

의견: 0

설명

Little Fran received a wooden frame in the shape of a regular polygon as a gift.
As polygon has \(n\) vertices, he also received {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 n\(on-ne\)ighboring 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, f2, . . . , 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, s2, . . . , s\(m\) be another such sequence. Two sequences are distinct if there exists an index \(i\) such that
\(f@@RISE_MATH_BLOCK_0@@i\).
As the number of such sequences can be huge, little Fran is only interested in its remainder modulo
\(10^{9} + 7\).

제약

Subtask 1 (12 points): \(n \le 9\), \(q \le 1\,000\)

Subtask 2 (16 points): \(x\)\(i = 1\), y\(i = i + 2\) for all \(i = 1\), . . . , \(n - 3\) and there are no events of type 1.

Subtask 3 (30 points): \(q = 1\)

Subtask 4 (12 points): n, \(q \le 1\,000\)

Subtask 5 (40 points): No additional constraints.

입력 형식

In the first line are integeres \(n\) and \(q\) (\(4 \le n \le 2 \cdot 10^{5}\), \(1 \le q \le 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@@RISE_MATH_BLOCK_0@@i\), y\(i \le n\)), the labels of vertices that the \(i-th\)
stick touches.
In each of the next \(q\) lines there is the integer \(t@@RISE_MATH_BLOCK_1@@i \le 2\)) that represents the type of event.
If \(t@@RISE_MATH_BLOCK_2@@i\), b\(i\), c\(i\), d\(i\) (\(1 \le a@@RISE_MATH_BLOCK_3@@i\), b\(i\)), (\(c@@RISE_MATH_BLOCK_4@@i = 2\), it is followed by an integer \(x@@RISE_MATH_BLOCK_5@@i \le 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.

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

1

12점

\(n \le 9\), \(q \le 1\,000\)

2

16점

\(x\)\(i = 1\), y\(i = i + 2\) for all \(i = 1\), . . . , \(n - 3\) and there are no events of type 1.

3

30점

\(q = 1\)

4

12점

n, \(q \le 1\,000\)

5

40점

No additional constraints.

예제 1
입력
4 3
1 3
2 1
1 1 3 2 4
2 1
출력
0 1
1 1
예제 2
입력
5 4
1 3
3 5
2 1
2 2
1 1 3 2 5
2 2
출력
1 1
2 1
1 1
예제 3
입력
9 3
1 5
1 7
2 4
2 5
5 7
7 9
2 1
1 2 5 1 4
2 1
출력
4 12
3 6
설명

Clarification of the first example:
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)).
Clarification of the second example:
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)).

문제 정보

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

출처 COCI 2023/2024 Contest 4

평가 및 의견

Lepeze

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

Log in to rate problems.

개별 의견

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

풀이 제출

Lepeze

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