QOJ.ac

QOJ

Limite de temps : 10 s Limite de mémoire : 256 MB Points totaux : 10 Communication

#17397. 矩阵编码 [B]

Statistiques

Algosia 和 Bajtek 非常忙。他们没有时间去构思原创题目,更不用说像参加今年信息学奥林匹克竞赛决赛时那样互相发送 $1000 \times 1000$ 的矩阵了。

Algosia 想要传给 Bajtek 一个正整数。不幸的是,正如他们最近的情况一样,他们被一个非常先进的计算机系统隔开了。Algosia 可以向计算机输入一个 $10 \times 10$ 的二进制矩阵,随后系统会对该矩阵的行和列进行置换,并将结果发送给 Bajtek。请编写一个程序,帮助 Algosia 和 Bajtek 进行 $t$ 次编码和解码。

交互

这是一道交互题。你的程序将运行两个副本——一个用于 Algosia,另一个用于 Bajtek。每个副本在输入的第一行都会收到单词 AlgosiaBajtek,这决定了该程序副本负责执行哪一方的操作。

两个程序在收到各自的身份标识后,会立即在输入中收到两个整数 $n$ 和 $t$ ($1 \le n \le 3 \cdot 10^{16}$, $1 \le t \le 25$),分别表示编码数字的上限和测试用例的数量。随后进行 $t$ 次交互。

在第 $i$ 次交互开始时,Algosia 收到一个整数 $n_i$ ($1 \le n_i \le n$)。她需要输出 10 行,每行包含 10 个字符。每个字符必须是 01。该矩阵的行和列将被置换,并以相同的格式发送到 Bajtek 进程的输入中。Bajtek 进程在收到矩阵后,应输出 Algosia 编码的数字 $n_i$。输出该数字后,下一个测试用例开始。

在输出每一部分内容后,必须刷新输出缓冲区,例如通过调用 cout.flush()fflush(stdout)

样例

输入格式 1

Algosia
20 2
12

输出格式 1

1110000000
1000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000
0000000000

说明

样例展示了交互过程的片段。交互器首先告知程序身份,随后告知 $n=20, t=2$。Algosia 收到数字 12 并输出对应的矩阵。随后 Bajtek 会收到置换后的矩阵并输出 12。此过程重复进行。

备注

  • 两个程序同时启动。程序运行时间测量为从交互器开始到结束的实际时间。
  • Algosia 只有在 Bajtek 解码前一个数字后,才会收到下一个数字。
  • Bajtek 进程在读取 $n$ 和 $t$ 后,不必阻塞等待输入,可以利用 Algosia 进程编码第一个数字的时间进行任意计算。在极端情况下,这可以使程序运行速度提高一倍。

评分

测试集由 10 组组成,每组可获得 0 或 1 分。各组中 $n$ 的限制如下:

组号 $n \le$
1 $10^{10}$
2 $10^{11}$
3 $10^{12}$
4 $10^{13}$
5 $10^{14}$
6 $10^{15}$
7 $5 \cdot 10^{15}$
8 $10^{16}$
9 $2 \cdot 10^{16}$
10 $3 \cdot 10^{16}$

本地测试

在“文件”部分提供了交互器 kodsoc.cpp。该文件中提供的交互器在发送给 Bajtek 之前不会对矩阵进行置换;除此区别外,它与 SIO 评测系统上的交互方式完全相同。请使用以下命令运行它:

python3 kodrun.py [solution] < [test]

其中 kodsoc.cppoi.h 必须位于同一文件夹中。交互器接收输入的格式在 kodsoc.cpp 的注释中有描述。可以通过运行 python3 kodrun.py -h 命令了解 kodrun.py 脚本的更多选项。

试运行

本题提供试运行。在试运行中,必须提供交互器的输入。试运行会返回程序的判定结果。试运行中使用的交互器与正式评测时相同。

公平竞争原则

禁止通过除游戏过程之外的任何方式在程序间进行通信,例如通过一个程序延迟发送动作而另一个程序读取时钟的方式。如果评审团发现程序间存在违规通信的企图,提交内容可能会被删除,在严重情况下,可能会决定取消该作者在整个竞赛中的参赛资格。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.