Universal Cup Judging System

Universal Cup

Time Limit: 2.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

如果一个正整数多重集 $s$ 满足 $s = \{x, x, x\}$,则称其为“刻子”(Pong)。 如果一个正整数多重集 $s$ 满足 $s = \{x, x+1, x+2\}$,则称其为“顺子”(Chow)。 如果一个正整数多重集 $s$ 满足 $s = \{x, x\}$,则称其为“雀头”(Eyes)。 如果一个正整数序列可以被划分为若干个(可以为零个)“刻子”、若干个(可以为零个)“顺子”以及恰好一个“雀头”,则称该序列为“和牌”(Mahjong)。

例如,序列 $s = \{1, 1, 4, 5, 1, 4, 4, 3\}$ 是“和牌”,因为它能被划分为 $\{1, 1, 1\}$、$\{3, 4, 5\}$ 和 $\{4, 4\}$。

对于给定的正整数序列,请判断其每一个前缀是否为“和牌”。

输入格式

每个测试点包含多组测试数据。第一行包含一个整数 $t$ ($1 \le t \le 10^5$),表示测试数据组数。

对于每组测试数据,唯一的一行包含一个整数 $n$ ($1 \le n \le 10^5$) 以及随后的 $n$ 个正整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$),分别表示整数序列的长度和序列中的元素。

保证所有测试数据中 $n$ 的总和不超过 $10^5$。

输出格式

对于每组测试数据,输出一行由 '0' 和 '1' 组成的字符串。如果长度为 $i$ 的前缀是“和牌”,则第 $i$ 个字符为 '1',否则为 '0'。

样例

样例输入 1

4
8 1 1 4 5 1 4 4 3
14 1 1 3 5 4 2 5 5 4 6 6 2 2 4
17 3 5 3 2 2 3 3 1 4 3 1 3 3 5 2 4 4
8 2 4 11 11 14 8 6 3

样例输出 1

01000001
01001001000001
00000000001000001
00000000

样例输入 2

10
2 1 1
3 1 1 1
3 1 2 3
5 1 1 1 1 1
5 1 1 1 2 2
5 1 1 1 2 3
8 1 1 1 1 1 1 2 3
5 2 2 1 1 1
5 3 2 1 1 1
8 3 2 1 1 1 1 1 1

样例输出 2

01
010
000
01001
01001
01001
01001001
01001
00001
00001001

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.