QOJ.ac

QOJ

时间限制: 1 s 内存限制: 64 MB 总分: 100

#569. 智力测试

统计

Byteotian Intelligence Test (BIT) 的任务之一是从初始序列中划掉一些数字,使得剩下的部分构成给定的序列。Byteasar 渴望成为 Byteotia 的 IQ 大师,但他并不擅长这类任务。由于熟能生巧,他打算进行大量练习。他希望你编写一个程序,通过快速验证他的答案来辅助他的训练。

输入格式

第一行包含一个整数 $m$ ($1 \le m \le 1\,000\,000$)。 第二行包含 $m$ 个整数 $a_1, a_2, \dots, a_m$ ($1 \le a_i \le 1\,000\,000$),由空格分隔,构成测试的初始序列。 第三行包含一个整数 $n$。 接下来的 $2n$ 行描述了需要通过从初始序列中划掉数字得到的序列。每个序列的描述占用连续的两行:第一行包含一个整数 $m_i$ ($1 \le m_i \le 1\,000\,000$),第二行包含一个长度为 $m_i$ 的整数序列 $b_{i,1}, b_{i,2}, \dots, b_{i,m_i}$ ($1 \le b_{i,j} \le 1\,000\,000$),由空格分隔。 你可以假设给定的 $n$ 个序列的总长度不超过 $1\,000\,000$。

输出格式

程序应向标准输出打印 $n$ 行。第 $i$ 行(对于 $1 \le i \le n$)应包含一个单词:如果第 $i$ 个输入序列可以通过从初始序列中划掉(即移除)一些(不一定连续的)数字得到,则输出 "TAK"(波兰语中的“是”),否则输出 "NIE"(波兰语中的“否”)。注意,仅需打印单词,无需引号。当然,划掉数字后剩余数字的顺序很重要,如样例所示。

样例

输入 1

7
1 5 4 5 7 8 6
4
5
1 5 5 8 6
3
2 2 2
3
5 7 8
4
1 5 7 4

输出 1

TAK
NIE
TAK
NIE

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.