Good Bye 2025
G
deCH OR Dations
Codeforces
2800
原题
← FH →
翻译中…

Due to supply chain issues in the North Pole (allegedly caused by a lazy elf), Santa is planning to give out hand-drawn circles as presents this Christmas. Please help him decorate them!

翻译中…

There are $2n$ equally spaced points around the circle, labeled $1,2,\ldots,2n$ in clockwise order. Santa has chosen $n$ chords with distinct endpoints, where chord $i$ connects the points $a_i$ and $b_i$. He draws these chords onto the circle one by one, in order.

翻译中…

After Santa has drawn the first $\ell$ chords, consider any non-empty subset $S$ of the $\ell$ chords and let $1\leq c_1 \lt c_2 \lt \cdots \lt c_{|S|}\leq \ell$ be their indices. $S$ is defined to be a chain if and only if chord $c_k$ intersects chord $c_{k+1}$ for all $1\leq k \lt |S|$. Note that $S$ is always a chain if $|S|=1$.

翻译中…

Santa does not want any chord to be the odd one out. Therefore, he considers the chords to be tight-knit if and only if every chord appears in an even number of chains, taken over all chains that are subsets of the first $\ell$ chords.

翻译中…

For each $\ell$ from $1$ to $n$, help Santa determine whether his chords are tight-knit.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line of each test case contains a single integer $n$ ($2\le n\le 5\cdot 10^5$) — the number of chords.

翻译中…

Then $n$ lines follow, the $i$-th line containing two integers $a_i$ and $b_i$ ($1\le a_i \lt b_i\le 2n$) — the endpoints of the $i$-th chord.

翻译中…

It is guaranteed that all endpoints are distinct.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $5\cdot 10^5$.

翻译中…

Output

翻译中…

For each test case, output a string of length $n$ — the $\ell$-th character should be $\texttt{1}$ if the first $\ell$ chords are tight-knit and $\texttt{0}$ otherwise.

翻译中…

Note

翻译中…

In the first test case, no pairs of chords intersect, and thus every chord appears in exactly one chain consisting of itself. Therefore, the chords are not tight-knit for all $\ell$.

翻译中…

In the second test case, below is an illustration and explanation after the first $\ell=1,2,3,4$ chords are drawn. Sets of chords are denoted as a set of the indices of the corresponding chords.

翻译中…

ExplanationIllustrationChains $\{1\}$. Appearances Chord $1$ appears in $1$ chain. Notes The chords are not tight-knit since chord $1$ is in an odd number of chains. Recall that a set containing a single chord is always a chain. imageChains $\{1\}$, $\{1,2\}$, and $\{2\}$. Appearances Chord $1$ appears in $2$ chains; Chord $2$ appears in $2$ chains. Notes The chords are tight-knit since every chord appears in an even number of chains. imageChains $\{1\}$, $\{1,2\}$, $\{2\}$, and $\{3\}$. Appearances Chord $1$ appears in $2$ chains; Chord $2$ appears in $2$ chains; Chord $3$ appears in $1$ chain. Notes The chords are not tight-knit since chord $3$ is in an odd number of chains. imageChains $\{1\}$, $\{1,2\}$, $\{1,2,4\}$, $\{2\}$, $\{2,4\}$, $\{3\}$, $\{3,4\}$, and $\{4\}$. Appearances Chord $1$ appears in $3$ chains; Chord $2$ appears in $4$ chains; Chord $3$ appears in $2$ chains; Chord $4$ appears in $4$ chains. Notes The chords are not tight-knit since chord $1$ is in an odd number of chains. Note that $\{2,3,4\}$ is not a chain since chord $2$ does not intersect chord $3$. image

翻译中…

Thus, we output $\mathtt{0100}$.

翻译中…

样例

Input #1
3
3
1 6
2 3
4 5
4
1 7
3 8
4 6
2 5
5
1 6
4 9
2 7
5 10
3 8
Output #1
000
0100
01111
InputCopy OutputCopy
题目信息
题号
2178G
所属比赛
时间限制
3 s
内存限制
512 MB
标签
位运算
数据结构
动态规划
哈希
概率论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。