CF652F.Ants on a Circle

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

n ants are on a circle of length m. An ant travels one unit of distance per one unit of time. Initially, the ant number i is located at the position s__i and is facing in the direction d__i (which is either L or R). Positions are numbered in counterclockwise order starting from some point. Positions of the all ants are distinct.

All the ants move simultaneously, and whenever two ants touch, they will both switch their directions. Note that it is possible for an ant to move in some direction for a half of a unit of time and in opposite direction for another half of a unit of time.

Print the positions of the ants after t time units.

有 n 只蚂蚁位于一个长度为 m 的圆周上。每只蚂蚁每单位时间移动 1 个单位距离。初始时,编号为 i 的蚂蚁位于位置 s__i,且朝向为 d__i(取值为 L 或 R)。位置沿逆时针方向从某一起点开始编号。所有蚂蚁的初始位置互不相同。

所有蚂蚁同时移动;每当两只蚂蚁相遇时,它们均立即掉转方向。注意:一只蚂蚁可能在某段时间内朝某一方向运动半个单位时间,随后在另一段时间内朝相反方向运动半个单位时间。

请输出经过 t 单位时间后各蚂蚁的位置。

输入格式

The first line contains three integers n, m and t (2 ≤ n ≤ 3·105, 2 ≤ m ≤ 109, 0 ≤ t ≤ 1018) — the number of ants, the length of the circle and the number of time units.

Each of the next n lines contains integer s__i and symbol d__i (1 ≤ s__i ≤ m and d__i is either L or R) — the position and the direction of the i-th ant at the start. The directions L and R corresponds to the clockwise and counterclockwise directions, respectively.

It is guaranteed that all positions s__i are distinct.

第一行包含三个整数 nn、mm 和 tt(2 ≤ n ≤ 3⋅1052 \leq n \leq 3\cdot10^5,2 ≤ m ≤ 1092 \leq m \leq 10^9,0 ≤ t ≤ 10180 \leq t \leq 10^{18})—— 分别表示蚂蚁的数量、圆环的长度以及时间单位数。

接下来的 nn 行中,每行包含一个整数 sis_i 和一个字符 did_i(1 ≤ si ≤ m1 \leq s_i \leq m,且 did_i 为 L 或 R)—— 分别表示第 ii 只蚂蚁的初始位置和初始方向。方向 L 和 R 分别对应顺时针和逆时针方向。

保证所有初始位置 sis_i 互不相同。

输出格式

Print n integers x__j — the position of the j-th ant after t units of time. The ants are numbered from 1 to n in order of their appearing in input.

输出 n 个整数 x__j —— 表示第 j 只蚂蚁在 t 单位时间后的位置。蚂蚁按输入中出现的顺序编号为 1 到 n。

输入输出样例

  • 输入#1

    2 4 8
    1 R
    3 L

    输出#1

    1 3
  • 输入#2

    4 8 6
    6 R
    5 L
    1 R
    8 L

    输出#2

    7 4 2 7
  • 输入#3

    4 8 2
    1 R
    5 L
    6 L
    8 R

    输出#3

    3 3 4 2

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

首页