CF652F.Ants on a Circle

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

nn ants are on a circle of length mm . An ant travels one unit of distance per one unit of time. Initially, the ant number ii is located at the position sis_{i} and is facing in the direction did_{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 tt time units.

输入格式

The first line contains three integers nn , mm and tt ( 2<=n<=3105,2<=m<=109,0<=t<=10182<=n<=3·10^{5},2<=m<=10^{9},0<=t<=10^{18} ) — the number of ants, the length of the circle and the number of time units.

Each of the next nn lines contains integer sis_{i} and symbol did_{i} ( 1<=si<=m1<=s_{i}<=m and did_{i} is either L or R) — the position and the direction of the ii -th ant at the start. The directions L and R corresponds to the clockwise and counterclockwise directions, respectively.

It is guaranteed that all positions sis_{i} are distinct.

输出格式

Print nn integers xjx_{j} — the position of the jj -th ant after tt units of time. The ants are numbered from 11 to nn in order of their appearing in input.

输入输出样例

  • 输入#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
    
首页