QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 256 MB 總分: 100 可 Hack ✓

#15609. 避免侵犯版权

统计

Busy Beaver 有 $X$ 张写有字母 M 的卡片,$Y$ 张写有字母 I 的卡片,以及 $Z$ 张写有字母 T 的卡片。 他想将这 $X + Y + Z$ 张卡片排成一排,并满足以下约束条件:

  • Busy Beaver 喜欢多样性,因此任意两张相邻的卡片不能相同;
  • Busy Beaver 想要避免被起诉,因此这一排中任意连续的三张卡片不能拼成 MIT 或 TIM。

请判断他是否能做到这一点。如果可以,输出一个可行的方案。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 50$) —— 测试用例的数量。

每个测试用例的唯一一行包含三个整数 $X, Y$ 和 $Z$ ($0 \le X, Y, Z \le 10^5$)。每个测试用例中至少有一张卡片 ($X + Y + Z > 0$)。

所有测试用例中 $X + Y + Z$ 的总和不超过 $3 \cdot 10^5$。

输出格式

对于每个测试用例,如果 Busy Beaver 无法排列所有 $X + Y + Z$ 张卡片,输出 NO

否则,输出 YES。然后输出一行 —— 一个长度为 $X + Y + Z$ 且由字符 M、I 和 T 组成的字符串,满足题目中的约束条件。

你可以以任何大小写形式输出答案(大写或小写)。例如,字符串 "yEs"、"yes"、"Yes" 和 "YES" 都将被识别为肯定回答。你也可以以任何大小写形式输出构造的字符串。

样例

输入样例 1

2
1 1 1
3 0 0

输出样例 1

YES
ITM
NO

说明

在第一个测试用例中,有 4 种可行的组合:ITM、IMT、MTI、TMI。ITM 是其中之一。它没有相邻的相同卡片,并且不包含 MIT 或 TIM。

在第二个测试用例中,只有一种可能的构造:MMM,但它是不合法的,因为存在相邻的 M。

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.