QOJ.ac

QOJ

Limite de temps : 3 s Limite de mémoire : 128 MB Points totaux : 100

#11171. 债务计数器

Statistiques

Bajtocji 的经济状况非常糟糕——这是 Bajterowicz 教授的观点。他决定引起公众对这一问题的关注,并委托 Bajtazar 的公司在首都中心安装了一个巨大的显示屏,用于展示 Bajtocji 当前的公共债务。

Bajtazar 负责编写显示屏的软件。该设备由 $n$ 位十进制数字组成。困难之处在于,输入到显示屏软件中的是两个长度最多为 $n-1$ 位的数字:Bajtocji 的内部债务(国内)和外部债务(国外)。而显示屏上需要显示这两个数字之和。

显示的数字需要实时更新。请帮助 Bajtazar 编写一个程序,以执行以下操作:

  • 修改内部债务的第 $i$ 位数字;
  • 修改外部债务的第 $i$ 位数字;
  • 查询总债务的第 $i$ 位数字。

输入格式

输入的第一行包含两个整数 $n$ 和 $z$ ($2 \le n \le 100\,000$, $1 \le z \le 100\,000$),分别表示显示屏的长度和要执行的操作次数。

第二行包含一个整数,表示 Bajtocji 初始的内部债务,为一个由 $n-1$ 位数字组成的字符串(该字符串可能包含前导零)。第三行以相同的格式给出初始的外部债务。

接下来的 $z$ 行包含操作描述。每行属于以下三种格式之一:

  • W i c – 将内部债务的第 $i$ 位数字修改为 $c$ ($1 \le i < n$, $0 \le c \le 9$);
  • Z i c – 将外部债务的第 $i$ 位数字修改为 $c$(限制同上);
  • S i – 查询总债务的第 $i$ 位数字 ($1 \le i \le n$)。

数字从右侧(从最低有效位)到左侧进行编号。

输出格式

对于输入中的每个 S 操作,输出一行。该行应包含一个数字 $c$ ($0 \le c \le 9$),作为对查询的回答。

样例

输入 1

5 6
7341
0150
S 3
W 3 0
S 3
Z 1 9
S 1
S 3

输出 1

4
1
0
2

说明 1

Bajtocji 的初始公共债务为 $7341 + 150 = 7491$,因此其第三位数字(从右侧起)为 $4$。第一次修改后,债务变为 $7041 + 150 = 7191$,因此第三位数字为 $1$。

子任务

测试集分为以下子任务。每个子任务的测试由一组或多组独立的测试用例组成。

子任务 条件 分值
1 $n, z \le 5000$ 30
2 在任何时刻,内部债务和外部债务的所有数字均属于集合 $\{0, 5\}$ 20
3 无额外限制 50

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.