Problem: There is a circle with a circumference of L. Each point on the circumference has a coordinate value, which represents the arc length from a certain reference point clockwise to the point. On this circumference, there are N ants. These ants are numbered 1 through N in order of increasing coordinate, and ant i is at coordinate X_i.  The N ants have just started walking. For each ant i, you are given the initial direction W_i. Ant i is initially walking clockwise if W_i is 1; counterclockwise if W_i is 2. Every ant walks at a constant speed of 1 per second. Sometimes, two ants bump into each other. Each of these two ants will then turn around and start walking in the opposite direction.  For each ant, find its position after T seconds.

Submission attempts (in order):




n,l,t=map(int,input().split())
x=[0 for i in range(n+1)]
w=[0 for i in range(n+1)]
ans=[]

for i in range(1,n+1):
    x[i],w[i]=map(int,input().split())
    if w[i]==1: a=(x[i]+t)%l
    else: a=(x[i]-t+l)%l
    ans.append(a)


crash=0
for i in range(2,n+1):
    if w[i] != w[1]:
        if w[1] == 1:
            crash += (t-((x[i]-x[1])/2)) // (l/2) + 1
        else:
            crash += (t-(l-(x[i]-x[1]))/2) // (l/2) + 1


ans.sort()
crash = int(crash)
for i in range(n):
    i = (i-crash)%n
    print(ans[i])
print(ans,crash)







n,l,t=map(int,input().split())
x=[0 for i in range(n+1)]
w=[0 for i in range(n+1)]
ans=[]　
w1=[]　
w2=[]　

for i in range(1,n+1):
    x[i],w[i]=map(int,input().split())
    if w[i]==1: a=(x[i]+t)%l; w1.append(x[i])
    if w[i]==2: a=(x[i]-t+l)%l; w2.append(x[i])
    ans.append(a)


k=0
for i in range(n):
    if w[i]==1:　
        if (x[i]+2*t)>=l:
            for j in range(x[i],x[i]+2*t+1): k+=w2.count(j)
            for j in range((x[i]+2*t+1)%l,x[i]): k+=w2.count(j)
        else:
            for j in range(x[i],x[i]+2*t+1): k+=w2.count(j)
        break　


ans.sort()
for i in range(n): print(ans[(i+k)%n])







n,l,t=map(int,input().split())
x=[]
w=[]
ans=[]

crash=0
for i in range(n):
    xx,ww=map(int,input().split())
    x.append(xx); w.append(ww)
    if w[i]==1: anss=(x[i]+t)%l
    else: anss=(x[i]-t+l)%l
    ans.append(anss)
    if i!=0 and w[i] != w[0]:
        if w[0] == 1: crash += (t-((x[i]-x[0])/2)) // (l/2) + 1
        else: crash += (t-(l-(x[i]-x[0]))/2) // (l/2) + 1


if w[0]==1: num0 =int(crash)%n
else: num0 =int(-crash)%n

nowplace = ans[0]
ans.sort()
num = ans.index(nowplace)
if w[0]==1 and ans.count(nowplace)==2: num += 1 

gap = num0-num
for i in range(n):
    i = (i+gap)%n
    print(ans[i])
print(ans)







n,l,t=map(int,input().split())
x=[]
w=[]
ans=[]

crash=0
for i in range(n):
    xx,ww=map(int,input().split())
    x.append(xx); w.append(ww)
    if w[i]==1: anss=(x[i]+t)%l
    else: anss=(x[i]-t+l)%l
    ans.append(anss)
    if i!=0 and w[i] != w[0]:
        if w[0] == 1: crash += (t-((x[i]-x[0])/2)) // (l/2) + 1
        else: crash += (t-(l-(x[i]-x[0]))/2) // (l/2) + 1


if w[0]==1: num0 =int(crash)%n
else: num0 =int(-crash)%n

nowplace = ans[0]
ans.sort()
num = ans.index(nowplace)
if w[0]==1 and ans.count(nowplace)==2: num += 1 

gap = num0-num
for i in range(n):
    i = (i-gap)%n
    print(ans[i])
print(ans)



n,l,t=map(int,input().split())
x=[]
w=[]
ans=[]
crash=0
for i in range(n):
    xx,ww=map(int,input().split())
    x.append(xx); w.append(ww)
    if w[i]==1: anss=(x[i]+t)%l
    else: anss=(x[i]-t+l)%l
    ans.append(anss)
    if i!=0 and w[i] != w[0]:
        if w[0] == 1: crash += (t-((x[i]-x[0])/2)) // (l/2) + 1
        else: crash += (t-(l-(x[i]-x[0]))/2) // (l/2) + 1

if w[0]==1: num0 =int(crash)%n
else: num0 =int(-crash)%n
nowplace = ans[0]
ans.sort()
num = ans.index(nowplace)
if w[0]==1 and ans.count(nowplace)==2: num += 1
gap = num-num0
for i in range(n):
    i = (i+gap)%n
    print(ans[i])

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Accepted