COCI2015/2016 Contest#4 F Solution

在森林覆盖的Endor月球上,据吉尼斯世界纪录记载,有银河系中最长的棍子。棍子上有N只欢快的变色龙,它们以1 m/s的速度向左右两个方向匀速移动,并且每只变色龙都有K种可能的颜色之一。当两只变色龙相撞时,它们会180度转向并交换颜色。问题要求计算每种颜色的变色龙离开棍子前的总行程。解决方案是将向右移动的变色龙视为静止,让向左的以两倍速度移动,通过一次扫描计算每个颜色的行程。注意在撞到最后一只静止的变色龙后的行程也不能忽略。
摘要由CSDN通过智能技术生成

Description
On the forest-filled moon of Endor there is, if we are to believe the Guinness Book of Records, the
longest stick in the whole galaxy. On that stick of L meters in length there are N cheerful chameleons.

Each chameleon is moving along the stick with constant speed of 1 m/s in one of two possible directions(left or right) and is colored in one of the possible K colors.

It is known that the chameleons of Endor worship the ancient ant laws that dictate that the walk
along the stick must be continued until the end of the stick is reached (which means getting off it),and when a collision with another chameleon takes place, you must turn 180 degrees and continue
the walk in the opposite direction. Additionally, after a chameleon colored in a moving to the left
collides with a chameleon colored in b moving to the right, the chameleon moving to the left before the collision takes the color of the chameleon moving to the right before the collision (so, color b), while the chameleon moving to the right before the collision takes a new color (a + b) mod K.

If you are given the initial positions, colors and directions of movement of all the chameleons, for each color determine the total trip taken by the chameleons in that color before getting off the

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值