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 2n equally spaced points around the circle, labeled 1,2,…,2n in clockwise order. Santa has chosen n chords with distinct endpoints, where chord i connects the points ai and bi. He draws these chords onto the circle one by one, in order.
After Santa has drawn the first ℓ chords, consider any non-empty subset S of the ℓ chords and let 1≤c1<c2<⋯<c∣S∣≤ℓ be their indices. S is defined to be a chain if and only if chord ck intersects chord ck+1 for all 1≤k<∣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 ℓ chords.
For each ℓ from 1 to n, help Santa determine whether his chords are tight-knit.
由于北极地区供应链出现问题(据称是由一名懒惰的精灵引起的),圣诞老人今年圣诞节计划发放手绘的圆作为礼物。请帮助他装饰这些圆!
圆周上均匀分布着 2n 个点,按顺时针顺序标记为 1,2,…,2n。圣诞老人已选出 n 条端点互不相同的弦,其中第 i 条弦连接点 ai 和 bi。他将按顺序依次画出这些弦。
在圣诞老人画完前 ℓ 条弦后,考虑这 ℓ 条弦的任意一个非空子集 S,并设其元素的索引为 1≤c1<c2<⋯<c∣S∣≤ℓ。当且仅当对所有 1≤k<∣S∣,弦 ck 与弦 ck+1 相交时,S 被定义为一条链。注意:若 ∣S∣=1,则 S 恒为一条链。
圣诞老人不希望任何一条弦成为“局外者”。因此,他将前 ℓ 条弦称为紧密关联的(tight-knit),当且仅当每条弦在所有由前 ℓ 条弦构成的链(即所有这些链的集合)中出现的次数均为偶数。
对每个从 1 到 n 的 ℓ,请帮助圣诞老人判断此时画出的弦是否是紧密关联的。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). The description of the test cases follows.
The first line of each test case contains a single integer n (2≤n≤5⋅105) — the number of chords.
Then n lines follow, the i-th line containing two integers ai and bi (1≤ai<bi≤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⋅105.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(2≤n≤5⋅105)—— 弦的数量。
接下来是 n 行,其中第 i 行包含两个整数 ai 和 bi(1≤ai<bi≤2n)—— 第 i 条弦的两个端点。
保证所有端点互不相同。
保证所有测试用例的 n 值之和不超过 5⋅105。
输出格式
For each test case, output a string of length n — the ℓ-th character should be 1 if the first ℓ chords are tight-knit and 0 otherwise.
对于每个测试用例,输出一个长度为 n 的字符串——其中第 ℓ 个字符应为 1 当且仅当前 ℓ 条弦是紧密关联的,否则为 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 ℓ.
In the second test case, below is an illustration and explanation after the first ℓ=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.
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.

Chains
- 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.

Chains
- 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.

Chains
- 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.

Thus, we output 0100.
在第一个测试用例中,没有任何两条弦相交,因此每条弦都恰好出现在仅包含它自身的链中。因此,对于所有 ℓ,这些弦都不是紧密连接的。
在第二个测试用例中,下图展示了在依次画出前 ℓ=1,2,3,4 条弦之后的示意图与说明。弦的集合以对应弦的索引所构成的集合表示。
说明
示意图
链
- 1。
出现次数
- 弦 1 出现在 1 个链中。
备注
- 这些弦不是紧密连接的,因为弦 1 出现在奇数个链中。
- 注意:仅含一条弦的集合恒为一个链。

链
- 1、1,2 和 2。
出现次数
- 弦 1 出现在 2 个链中;
- 弦 2 出现在 2 个链中。
备注
- 这些弦是紧密连接的,因为每条弦均出现在偶数个链中。

链
- 1、1,2、2 和 3。
出现次数
- 弦 1 出现在 2 个链中;
- 弦 2 出现在 2 个链中;
- 弦 3 出现在 1 个链中。
备注
- 这些弦不是紧密连接的,因为弦 3 出现在奇数个链中。

链
- 1、1,2、1,2,4、2、2,4、3、3,4 和 4。
出现次数
- 弦 1 出现在 3 个链中;
- 弦 2 出现在 4 个链中;
- 弦 3 出现在 2 个链中;
- 弦 4 出现在 4 个链中。
备注
- 这些弦不是紧密连接的,因为弦 1 出现在奇数个链中。
- 注意:2,3,4 不是一个链,因为弦 2 与弦 3 不相交。

因此,我们输出 0100。
输入解题思路,AI测评打分。不知道怎么写?