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 n robots and m spikes, each located at a specific point on the number line. The i-th robot is located at position ai, and the i-th spike is located at position bi. If a robot touches a spike, it dies.
k 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 i (1≤i≤k), output how many robots are still alive after the first i instructions have been processed.
存在一条无限长的数轴。
在该数轴上有 n 个机器人和 m 个尖刺,各自位于数轴上的特定位置。第 i 个机器人位于位置 ai,第 i 个尖刺位于位置 bi。若一个机器人触碰到某个尖刺,则该机器人死亡。
共有 k 条指令发送给这些机器人,每条指令指示机器人向左移动一个单位或向右移动一个单位。
对每个 i(1≤i≤k),输出在执行完前 i 条指令后仍然存活的机器人数量。
输入格式
The first line of the input contains a single integer t (1≤t≤104) — the number of test cases.
The first line of each test case contains three integers n,m,k (1≤n,m,k≤2⋅105) — the number of robots, spikes, and instructions respectively.
The second line contains n integers a1,a2,…,an (0≤ai≤109) — the locations of the robots. It is guaranteed that all elements of a are distinct.
The third line contains m integers b1,b2,…,bm (0≤bi≤109) — the locations of the spikes. It is guaranteed that all elements of b are distinct.
The fourth line contains a string of length k — the instructions transmitted to the robots. Each character is either L, representing an instruction to move to the left, or R, representing an instruction to move to the right.
It is guaranteed that the sum of each of n,m,k over all test cases does not exceed 2⋅105.
Additional constraint: it is guaranteed that there are no robots and spikes at the same position.
输入的第一行包含一个整数 t(1≤t≤104),表示测试用例的数量。
每个测试用例的第一行包含三个整数 n,m,k(1≤n,m,k≤2⋅105),分别表示机器人的数量、尖刺的数量以及指令的数量。
每个测试用例的第二行包含 n 个整数 a1,a2,…,an(0≤ai≤109),表示机器人的位置。保证数组 a 中所有元素互不相同。
每个测试用例的第三行包含 m 个整数 b1,b2,…,bm(0≤bi≤109),表示尖刺的位置。保证数组 b 中所有元素互不相同。
每个测试用例的第四行包含一个长度为 k 的字符串,表示发送给机器人的指令序列。其中每个字符要么是 L(表示向左移动),要么是 R(表示向右移动)。
保证所有测试用例中 n,m,k 各自的总和均不超过 2⋅105。
附加约束:保证不存在机器人与尖刺位于同一位置的情况。
输出格式
Output k integers, where the i-th integer indicates how many robots are alive after the first i 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.
输出 k 个整数,其中第 i 个整数表示处理完前 i 条指令后仍存活的机器人数量。
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→1, so it will not die.
- The second robot will move to positions 1→0→1→2, so it will die after processing the third instruction, since there is a spike at position 2.
For the second test case, both robots will die after moving once.
对于第一个测试用例:
- 第一个机器人将移动至位置 0→−1→0→1,因此不会死亡。
- 第二个机器人将移动至位置 1→0→1→2,因此在执行第三条指令后会死亡,因为在位置 2 处存在尖刺。
对于第二个测试用例,两个机器人都将在移动一次后死亡。
输入解题思路,AI测评打分。不知道怎么写?