QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#10305. Bulbel

統計

我们定义一个 bitset 是一个 $w$ 位 $01$ 串。定义一个 $w\times w$ 的 $01$ 矩阵 $M$ 的 bitset 表示为一个长度为 $w$ 的 bitset 序列 $b_1,\ldots,b_w$,其中 $b_i$ 是将 $M$ 的第 $i$ 行看作一个 $01$ 串对应的 bitset,其中第 $j$ 列的元素位于 bitset 的第 $j$ 位。

有一个 $w\times w$ 矩阵 $M$ 的 bitset 表示,存储在 $b_1,\ldots,b_w$(但你不能直接访问它们的值),你需要求出其转置 $M^T$ 的 bitset 表示,最终存储在 $b_1,\ldots,b_w$ 中。你总共可以调用 $b_1,\ldots,b_{10^5}$ 这 $10^5$ 个 bitset,其中 $b_{w+1},\ldots,b_{10^5}$ 初始全零。你可以进行以下操作:

  • AS x y:令 $b_x\leftarrow b_y$。
  • AND x y z:令 $b_x\leftarrow b_y\land b_z$,其中 $\land$ 为按位与。
  • OR x y z:令 $b_x\leftarrow b_y\lor b_z$,其中 $\lor$ 为按位或。
  • XOR x y z:令 $b_x\leftarrow b_y\oplus b_z$,其中 $\oplus$ 为按位异或。
  • SET x y a v:令 $b_x$ 成为将 $b_y$ 的第 $a$ 位($a\in [0,w)$)修改为 $v$($v\in \{0,1\}$)后的结果(不改变 $b_y$)。
  • SH x y a:令 $b_x$ 成为将 $b_y$ 左移 $a$ 位($a\in (-w,w)$)后的结果(不改变 $b_y$,若 $a < 0$ 则为右移 $-a$ 位,多出来的位补 $0$)。
  • SUB x s y:令 $b_x\leftarrow b_{s+b_y}$,其中把 $b_y$ 视作一个二进制数,要求 $-10^5\leq s\leq 10^5,\ 1\leq s+b_y\leq 10^5$。

你的得分与你的操作次数有关,详见评分标准。

输入格式

从标准输入读入数据。

第一行:一个整数 $w$。

输出格式

输出到标准输出。

第一行:一个整数 $m$,表示你的操作次数。

接下来 $m$ 行:每行表示一个操作。操作将按照输出顺序执行。

样例

输入

2

输出

10
SET 3 3 0 1
SET 4 4 1 1
AND 5 1 3
AND 6 1 4
AND 7 2 3
AND 8 2 4
SH 9 6 -1
SH 10 7 1
OR 1 5 10
OR 2 8 9

子任务

$\text{Subtask 1}(5\%)$:$w=2$。

$\text{Subtask 2}(10\%)$:$w=128$。

$\text{Subtask 3}(36\%)$:$w=256$。

$\text{Subtask 4}(49\%)$:$w=1024$。

评分方式

令 $m$ 为你的操作次数。

你在某个测试点上的得分为:若你的输出错误,得分为 $0$,否则得分为 $f(m)$。你在一个子任务上的得分为在其中所有测试点上得分的最小值。

对于 $\text{Subtask 1}$,$f(m)=[m\leq 10^5]\times 5$。

对于 $\text{Subtask 2}$,$f(m)=[m\leq 10^5]\times 10$。

对于 $\text{Subtask 3}$,$f(m)=\begin{cases}0 & (m>262144)\\\dfrac{8}{3}\left(4-\dfrac{m}{65536}\right)^2 & (65536< m\leq 262144)\\ 36-\dfrac{64}{3}\left(\dfrac{m}{65536}-\dfrac{1}{4}\right)^2 & (16384 < m\leq 65536)\\ 36 & (m\leq 16384)\end{cases}$。

  • 它是个连续函数。作为参考,当 $f(65536)=24$。

对于 $\text{Subtask 4}$,$f(m)=\begin{cases}0 & (m>80000)\\\dfrac{3}{4000}(80000-m) & (40000 < m\leq 80000)\\ 48-\dfrac{9}{2282}(m-35436) & (35435< m\leq 40000)\\ 49 & (m\leq 35435)\end{cases}$。

  • 它在 $(35435,+\infty)$ 上是个连续函数。作为参考,当 $f(40000)=30,\ f(35436)=48$。
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.