| TeamsCode Summer 2024 Novice Division |
|---|
| Закончено |
Given the array $$$[ 1,2, \ldots ,2 \cdot n ]$$$, partition it into $$$2$$$ subsequences $$$a$$$ and $$$b$$$ of length $$$n$$$ such that each element of the original array is present in one of $$$a$$$ or $$$b$$$. A subsequence is a sequence that can be derived from the given array by deleting zero or more elements without changing the order of the remaining elements.
For each index $$$i$$$ ($$$ 1 \le i \le n$$$), you are given one of the three following constraints: $$$a_i+b_i = v_i$$$, $$$|a_i-b_i| = v_i$$$, or $$$\text{max}(a_i, b_i) = v_i$$$. Find the number of possible subsequences $$$a$$$ and $$$b$$$, modulo $$$10^9+7$$$. It is guaranteed there exists at least one partition that satisfies the constraints.
The first line of input contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$).
The next $$$n$$$ lines each contain two integers $$$t_i$$$ and $$$v_i$$$ ($$$1 \le t_i \le 3, 1 \le v_i \lt 4 \cdot n$$$) — the constraints on $$$a_i$$$ and $$$b_i$$$.
If $$$t_i=1$$$, $$$v_i=a_i+b_i$$$.
If $$$t_i=2$$$, $$$v_i=|a_i-b_i|$$$.
If $$$t_i=3$$$, $$$v_i=\text{max}(a_i, b_i)$$$.
—
There are $$$10$$$ tests, not including samples. Each test is worth $$$\frac{100}{10}=10$$$ points.
Output a single integer — the number of possible ways to partition the array $$$[ 1,2, \ldots 2 \cdot n ]$$$ into $$$a$$$ and $$$b$$$ that satisfy the constraints. Output your answer modulo $$$10^9+7$$$.
51 53 53 62 21 18
4
In the sample test, the $$$4$$$ ways to partition the array are:
—
Problem Idea: superhelen
Problem Preparation: xug
Occurrences: Novice D
| Название |
|---|


