10881 - Piotr's Ants
来源:互联网 发布:涌金软件 编辑:程序博客网 时间:2024/06/14 12:03
#include<iostream>#include<algorithm>using namespace std;char condition[3][10]={"L","Turning","R"};struct Ant{int id;//编号 int p;//位置 int d;//状态 bool operator<(const Ant&a)const{return p<a.p;}}before[10001],after[10001];int order[10001];int main(){int L,T,n,maxn,p,d;char ch;scanf("%d",&maxn);for(int count=1;count<=maxn;count++){scanf("%d%d%d",&L,&T,&n);for(int i=0;i<n;i++){scanf("%d %c",&p,&ch);d=(ch=='L'?-1:1);before[i]=(Ant){i,p,d};after[i]=(Ant){0,p+d*T,d};}sort(before,before+n);for(int i=0;i<n;i++) order[before[i].id]=i;sort(after,after+n);for(int i=0;i<n-1;i++) if(after[i].p==after[i+1].p)after[i].d=after[i+1].d=0;printf("Case #%d:\n",count); for(int i=0;i<n;i++){int a=order[i];if(after[a].p<0||after[a].p>L)printf("Fell off\n");else printf("%d %s\n",after[a].p,condition[after[a].d+1]);}cout<<endl; } return 0;}
题目地址https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=456&page=show_problem&problem=1822
0 0
- 10881 - Piotr's Ants
- 10881 - Piotr's Ants
- 10881 - Piotr's Ants
- 10881 - Piotr's Ants
- UVa - 10881 - Piotr's Ants
- uva 10881 - Piotr's Ants
- Uva-10881-Piotr's Ants
- uva 10881 - Piotr's Ants
- UVa 10881 Piotr's Ants
- UVA 10881 Piotr's Ants
- Piotr's ants UVA 10881
- UVa 10881 - Piotr's Ants
- UVa 10881 Piotr's Ants
- UVA - 10881 Piotr's Ants
- uva 10881 Piotr's Ants
- UVA - 10881 Piotr's Ants
- UVa 10881 - Piotr's Ants
- UVa 10881 - Piotr's Ants
- poj 1260 Pearls
- Spring Boot 1.4.3搭建
- 计时函数clock()
- 详解Android开发中UI的五种布局管理器教程
- 批处理和获取主键值
- 10881 - Piotr's Ants
- Java基本(1)
- LeetCode Group Anagrams
- PLSQL Function
- 欢迎使用CSDN-markdown编辑器
- 2016,青春无悔
- Fusion 360 API:特征与多体模型的布尔操作
- day01_计算机基础知识
- day02_Java语言基础