classBall:def__init__(self,position,direction):self.position=positionself.direction=directionn,l,t=input().split()n=int(n)l=int(l)t=int(t)count=0news=input().split()ball=...
class Ball:
def __init__(self, position, direction):
self.position = position
self.direction = direction
n,l,t = input().split()
n = int(n)
l = int(l)
t = int(t)
count = 0
news = input().split()
ball = [0]
for i in range(0,n):
ball.append(Ball(news[i],1))
while t>=0:
for i in range(0,n):#端点反向
if ball[i].direction ==1:
ball[i].position += 1
if ball[i].position == l:
ball[i].direction *= -1
else:
ball[i].position -= 1
if ball[i].position == 0:
ball[i].direction *= -1
for i in range(0,n-1):
for j in range(i+1,n):#碰撞反向
if ball[i].position == ball[j].position:
ball[i].direction *= -1
ball[j].direction *= -1
t -= 1
for i in range(n):#打印
if i==n:
print(ball[i].position,end='')
else:
print(ball[i].position+" ", end='')
展开