CF2178G.deCH OR Dations

省选/NOI-

通过率:0%

时间限制:3.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 2n2n equally spaced points around the circle, labeled 1,2,…,2n1,2,\ldots,2n in clockwise order. Santa has chosen nn chords with distinct endpoints, where chord ii connects the points aia_i and bib_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 SS of the ℓ\ell chords and let 1≤c1<c2<⋯<c∣S∣≤ℓ1\leq c_1 \lt c_2 \lt \cdots \lt c_{|S|}\leq \ell be their indices. SS is defined to be a chain if and only if chord ckc_k intersects chord ck+1c_{k+1} for all 1≤k<∣S∣1\leq k \lt |S|. Note that SS is always a chain if ∣S∣=1|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 11 to nn, help Santa determine whether his chords are tight-knit.

由于北极地区供应链出现问题(据称是由一名懒惰的精灵引起的),圣诞老人今年圣诞节计划发放手绘的圆作为礼物。请帮助他装饰这些圆!

圆周上均匀分布着 2n2n 个点,按顺时针顺序标记为 1,2,…,2n1,2,\ldots,2n。圣诞老人已选出 nn 条端点互不相同的弦,其中第 ii 条弦连接点 aia_i 和 bib_i。他将按顺序依次画出这些弦。

在圣诞老人画完前 ℓ\ell 条弦后,考虑这 ℓ\ell 条弦的任意一个非空子集 SS,并设其元素的索引为 1≤c1<c2<⋯<c∣S∣≤ℓ1\leq c_1 \lt c_2 \lt \cdots \lt c_{|S|}\leq \ell。当且仅当对所有 1≤k<∣S∣1\leq k \lt |S|,弦 ckc_k 与弦 ck+1c_{k+1} 相交时,SS 被定义为一条链。注意:若 ∣S∣=1|S|=1,则 SS 恒为一条链。

圣诞老人不希望任何一条弦成为“局外者”。因此,他将前 ℓ\ell 条弦称为紧密关联的(tight-knit),当且仅当每条弦在所有由前 ℓ\ell 条弦构成的链(即所有这些链的集合)中出现的次数均为偶数。

对每个从 11 到 nn 的 ℓ\ell,请帮助圣诞老人判断此时画出的弦是否是紧密关联的。

输入格式

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

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

Then nn lines follow, the ii-th line containing two integers aia_i and bib_i (1≤ai<bi≤2n1\le a_i \lt b_i\le 2n) — the endpoints of the ii-th chord.

It is guaranteed that all endpoints are distinct.

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

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1041 \le t \le 10^4)。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(2≤n≤5⋅1052\le n\le 5\cdot 10^5)—— 弦的数量。

接下来是 nn 行,其中第 ii 行包含两个整数 aia_i 和 bib_i(1≤ai<bi≤2n1\le a_i \lt b_i\le 2n)—— 第 ii 条弦的两个端点。

保证所有端点互不相同。

保证所有测试用例的 nn 值之和不超过 5⋅1055\cdot 10^5。

输出格式

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

对于每个测试用例,输出一个长度为 nn 的字符串——其中第 ℓ\ell 个字符应为 1\texttt{1} 当且仅当前 ℓ\ell 条弦是紧密关联的,否则为 0\texttt{0}。

输入输出样例

  • 输入#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

    输出#1

    000
    0100
    01111

说明/提示

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 ℓ=1,2,3,4\ell=1,2,3,4 chords are drawn. Sets of chords are denoted as a set of the indices of the corresponding chords.

Explanation

Illustration

Chains

  • 1{1}.

Appearances

  • Chord 11 appears in 11 chain.

Notes

  • The chords are not tight-knit since chord 11 is in an odd number of chains.
  • Recall that a set containing a single chord is always a chain.

Chains

  • 1{1}, 1,2{1,2}, and 2{2}.

Appearances

  • Chord 11 appears in 22 chains;
  • Chord 22 appears in 22 chains.

Notes

  • The chords are tight-knit since every chord appears in an even number of chains.

Chains

  • 1{1}, 1,2{1,2}, 2{2}, and 3{3}.

Appearances

  • Chord 11 appears in 22 chains;
  • Chord 22 appears in 22 chains;
  • Chord 33 appears in 11 chain.

Notes

  • The chords are not tight-knit since chord 33 is in an odd number of chains.

Chains

  • 1{1}, 1,2{1,2}, 1,2,4{1,2,4}, 2{2}, 2,4{2,4}, 3{3}, 3,4{3,4}, and 4{4}.

Appearances

  • Chord 11 appears in 33 chains;
  • Chord 22 appears in 44 chains;
  • Chord 33 appears in 22 chains;
  • Chord 44 appears in 44 chains.

Notes

  • The chords are not tight-knit since chord 11 is in an odd number of chains.
  • Note that 2,3,4{2,3,4} is not a chain since chord 22 does not intersect chord 33.

Thus, we output 0100\mathtt{0100}.

在第一个测试用例中,没有任何两条弦相交,因此每条弦都恰好出现在仅包含它自身的链中。因此,对于所有 ℓ\ell,这些弦都不是紧密连接的。

在第二个测试用例中,下图展示了在依次画出前 ℓ=1,2,3,4\ell=1,2,3,4 条弦之后的示意图与说明。弦的集合以对应弦的索引所构成的集合表示。

说明

示意图

链

  • 1{1}。

出现次数

  • 弦 11 出现在 11 个链中。

备注

  • 这些弦不是紧密连接的,因为弦 11 出现在奇数个链中。
  • 注意:仅含一条弦的集合恒为一个链。

链

  • 1{1}、1,2{1,2} 和 2{2}。

出现次数

  • 弦 11 出现在 22 个链中;
  • 弦 22 出现在 22 个链中。

备注

  • 这些弦是紧密连接的,因为每条弦均出现在偶数个链中。

链

  • 1{1}、1,2{1,2}、2{2} 和 3{3}。

出现次数

  • 弦 11 出现在 22 个链中;
  • 弦 22 出现在 22 个链中;
  • 弦 33 出现在 11 个链中。

备注

  • 这些弦不是紧密连接的,因为弦 33 出现在奇数个链中。

链

  • 1{1}、1,2{1,2}、1,2,4{1,2,4}、2{2}、2,4{2,4}、3{3}、3,4{3,4} 和 4{4}。

出现次数

  • 弦 11 出现在 33 个链中;
  • 弦 22 出现在 44 个链中;
  • 弦 33 出现在 22 个链中;
  • 弦 44 出现在 44 个链中。

备注

  • 这些弦不是紧密连接的,因为弦 11 出现在奇数个链中。
  • 注意:2,3,4{2,3,4} 不是一个链,因为弦 22 与弦 33 不相交。

因此,我们输出 0100\mathtt{0100}。

输入解题思路,AI测评打分。不知道怎么写?

首页