uva10881专题

uva10881 ants

#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define MAX_N 10010struct ant{int id;//记录输入顺序int p; //每只蚂蚁位置int d; //每只蚂蚁方向,-1左,0正在碰撞,1右;bool operator < (const ant& a)

UVA10881 Piotr‘s Ants 思维

https://www.luogu.com.cn/problem/UVA10881 给出若干只蚂蚁的初始位置和方向,他们的爬行速度都是 1 1 1,相遇时同时掉头,问经过若干时间之后的位置和朝向 我们首先可以发现,因为蚂蚁只要相遇就会掉头,所以他们的相对位置肯定不会变,也就是说原来如果 2 2 2在 1 1 1和 3 3 3中间,那么无论怎么走, 2 2 2还是在 1 1 1和 3 3 3中间接