10881专题

uva 10881 - Piotr's Ants(排序)

题目链接:10881 - Piotr's Ants 题目大意:在一个长为L的木棒上有n只蚂蚁,给出蚂蚁的初始位置以及方向,问说移动T秒后各个蚂蚁的位置以及状态,如果两只蚂蚁在移动的过程中相撞,则会同时掉头。 解题思路:问题只要解决说两只蚂蚁相撞的情况就差不多了,其实从整体上来看(不考虑蚂蚁的编号),“相撞”和对穿而过“是一样的,只不过移动到那个位置的蚂蚁并不是先前的那只。所以说只要

Piotr's Ants,UVa 10881

【原题】 Piotr likes playing with ants. He has n of them on a horizontal pole L cm long. Each ant is facing either left or right and walks at a constant speed of 1 cm/s. When two ants bump into each othe