QOJ.ac

QOJ

Limite de temps : 2.0 s Limite de mémoire : 512 MB Points totaux : 100 Hackable ✓

#9360. 体面的序列

Statistiques

如果一个数组 $a$ 可以被拆分为两个连续的部分(可以为空),使得第一部分(前缀)是非递减的,而第二部分(后缀)是非递增的,则称该数组 $a$ 是“体面的”(decent)。例如,$[1, 2, 3]$、$[1, 2, 2, 1]$ 和 $[3]$ 是体面的,而 $[3, 2, 2, 8]$ 则不是。

现在有一个包含 $n$ 个整数的数组 $a$,但你并不知道它的具体内容。不过,你已知 $n$ 个整数 $l_i$ 和 $n$ 个整数 $r_i$。已知对于所有 $1$ 到 $n$ 的下标 $i$,都有 $l_i \le a_i \le r_i$。请问 $a$ 是否一定是体面的?

你需要给出以下三种答案之一: 1. $a$ 一定是体面的。 2. $a$ 一定不是体面的。 3. 以上两种情况都不是。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 10^6$),表示数组 $a$ 的长度。

接下来的 $n$ 行,每行包含两个整数 $l_i$ 和 $r_i$ ($1 \le l_i \le r_i \le 10^9$),描述了元素 $a_i$ 的取值范围。

输出格式

如果 $a$ 一定是体面的,输出 “TAK”(不含引号)。 如果 $a$ 一定不是体面的,输出 “NEIN”(不含引号)。 否则,输出一个长度在 5 到 100 之间,由大小写英文字母组成的任意字符串。如果你输出的内容非常不恰当,可能会收到 Presentation Error。样例中给出的两种可能的答案均不被视为不恰当。

样例

样例输入 1

3
3 4
2 5
1 1

样例输出 1

TAK

样例输入 2

4
3 4
1 3
1 2
3 10

样例输出 2

NEIN

样例输入 3

3
1 10
1 10
1 10

样例输出 3

NEITHER

样例输入 4

4
1 2
1 1
1 1
1 2

样例输出 4

Secret

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.