CF2185E.The Robotic Rush

普及/提高-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There exists an infinitely long number line.

On the number line, there are nn robots and mm spikes, each located at a specific point on the number line. The ii-th robot is located at position aia_i, and the ii-th spike is located at position bib_i. If a robot touches a spike, it dies.

kk instructions are transmitted to the robots, with each instruction being to either move left by one unit or to move right by one unit.

For each value ii (1≤i≤k1 \leq i \leq k), output how many robots are still alive after the first ii instructions have been processed.

存在一条无限长的数轴。

在该数轴上有 nn 个机器人和 mm 个尖刺,各自位于数轴上的特定位置。第 ii 个机器人位于位置 aia_i,第 ii 个尖刺位于位置 bib_i。若一个机器人触碰到某个尖刺,则该机器人死亡。

共有 kk 条指令发送给这些机器人,每条指令指示机器人向左移动一个单位或向右移动一个单位。

对每个 ii(1≤i≤k1 \leq i \leq k),输出在执行完前 ii 条指令后仍然存活的机器人数量。

输入格式

The first line of the input contains a single integer tt (1≤t≤1041 \leq t \leq 10^4) — the number of test cases.

The first line of each test case contains three integers n,m,kn, m, k (1≤n,m,k≤2⋅1051 \le n, m, k \le 2 \cdot 10^5) — the number of robots, spikes, and instructions respectively.

The second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (0≤ai≤1090 \le a_i \le 10^9) — the locations of the robots. It is guaranteed that all elements of aa are distinct.

The third line contains mm integers b1,b2,…,bmb_1, b_2, \ldots, b_m (0≤bi≤1090 \le b_i \le 10^9) — the locations of the spikes. It is guaranteed that all elements of bb are distinct.

The fourth line contains a string of length kk — the instructions transmitted to the robots. Each character is either L\texttt{L}, representing an instruction to move to the left, or R\texttt{R}, representing an instruction to move to the right.

It is guaranteed that the sum of each of n,m,kn, m, k over all test cases does not exceed 2⋅1052 \cdot 10^5.

Additional constraint: it is guaranteed that there are no robots and spikes at the same position.

输入的第一行包含一个整数 tt(1≤t≤1041 \leq t \leq 10^4),表示测试用例的数量。

每个测试用例的第一行包含三个整数 n,m,kn, m, k(1≤n,m,k≤2⋅1051 \le n, m, k \le 2 \cdot 10^5),分别表示机器人的数量、尖刺的数量以及指令的数量。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(0≤ai≤1090 \le a_i \le 10^9),表示机器人的位置。保证数组 aa 中所有元素互不相同。

每个测试用例的第三行包含 mm 个整数 b1,b2,…,bmb_1, b_2, \ldots, b_m(0≤bi≤1090 \le b_i \le 10^9),表示尖刺的位置。保证数组 bb 中所有元素互不相同。

每个测试用例的第四行包含一个长度为 kk 的字符串,表示发送给机器人的指令序列。其中每个字符要么是 L\texttt{L}(表示向左移动),要么是 R\texttt{R}(表示向右移动)。

保证所有测试用例中 n,m,kn, m, k 各自的总和均不超过 2⋅1052 \cdot 10^5。

附加约束:保证不存在机器人与尖刺位于同一位置的情况。

输出格式

Output kk integers, where the ii-th integer indicates how many robots are alive after the first ii instructions have been processed.

For Python users, make sure to select PyPy3 / PyPy2 (depending on which version of Python you're using) instead of Python3 or Python2 when submitting.

输出 kk 个整数,其中第 ii 个整数表示处理完前 ii 条指令后仍存活的机器人数量。

Python 用户在提交时,请务必选择 PyPy3 或 PyPy2(取决于您使用的 Python 版本),而不要选择 Python3 或 Python2。

输入输出样例

  • 输入#1

    3
    2 1 3
    0 1
    2
    LRR
    2 3 3
    2 4
    1 3 5
    LRL
    3 2 3
    1 3 7
    9 6
    RRL

    输出#1

    2 2 1 
    0 0 0 
    3 2 2

说明/提示

For the first test case:

  • The first robot will move to positions 0→−1→0→10 \rightarrow -1 \rightarrow 0 \rightarrow 1, so it will not die.
  • The second robot will move to positions 1→0→1→21 \rightarrow 0 \rightarrow 1 \rightarrow 2, so it will die after processing the third instruction, since there is a spike at position 22.

For the second test case, both robots will die after moving once.

对于第一个测试用例:

  • 第一个机器人将移动至位置 0→−1→0→10 \rightarrow -1 \rightarrow 0 \rightarrow 1,因此不会死亡。
  • 第二个机器人将移动至位置 1→0→1→21 \rightarrow 0 \rightarrow 1 \rightarrow 2,因此在执行第三条指令后会死亡,因为在位置 22 处存在尖刺。

对于第二个测试用例,两个机器人都将在移动一次后死亡。

输入解题思路,AI测评打分。不知道怎么写?

首页