QOJ.ac

QOJ

總分: 100

#10670. Bytie 的显示屏 [B]

统计

Byteman 在他儿子 Bytie 三岁生日时送了一份精美的礼物。这是一个由 $l$ 个元素组成的显示屏,每个元素排成一行,并被分为七个

单个元素。长六边形代表段。

这些元素可以通过开启或关闭某些段来显示数字,如下图所示。其他段的组合不代表任何数字。

0 到 9 的数字表示。黑色段为开启,白色段为关闭。

Bytie 给 Byteman 出了一道谜题:“如果我们被允许:

  • 无限次交换显示屏上的任意两个元素,以及
  • 最多开启或关闭 $n$ 个不同的段,

我们能在显示屏上得到的最大数字是多少?”

请注意,最终显示屏必须显示一个正确的数字(中间过程不需要),并且我们只能交换整个元素。

Byteman 无法回答这个问题,所以他认为你可能可以帮助他。你的任务是解决 Bytie 的谜题。

输入格式

标准输入的第一行包含一个整数 $k$,表示测试用例的数量。

  • $1 \le k \le 50$

接下来的 $k$ 行,每行包含三个整数 $n_i, l_i, a_i$ ($0 \le n_i \le 200\,000, 1 \le l_i \le 100\,000$)。第一个整数是我们可以开关段的最大次数,而 $a_i$ 是一个长度为 $l_i$ 的数字(允许前导零),表示显示屏的当前状态。

输出格式

对于每个测试用例,你的程序应输出一行,包含一个长度为 $l_i$ 的整数(允许前导零)。这应该是遵循 Bytie 规则所能得到的最大数字。

样例

输入 1

1
1 2 10

输出 1

81

说明

Bytie 可以先交换 1 和 0,然后开启中间的水平段。结果,显示屏将显示 81。在这种情况下,不可能得到更大的数字。

---------------------------

初始状态以及交换并开启中间水平段后的状态。


或者逐个上传:

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.