标签:
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 8522 | Accepted: 3682 |
Description
Input

Output
Sample Input
4 5 4 2 2 1 1 E 5 4 W 1 F 7 2 F 7 5 4 2 4 1 1 E 5 4 W 1 F 3 2 F 1 1 L 1 1 F 3 5 4 2 2 1 1 E 5 4 W 1 L 96 1 F 2 5 4 2 3 1 1 E 5 4 W 1 F 4 1 L 1 1 F 20
Sample Output
Robot 1 crashes into the wall Robot 1 crashes into robot 2 OK Robot 1 crashes into robot 2
Source
#include<iostream>
#include<cstring>
#include<cstdio>
//#include <bits/stdc++.h>
using namespace std;
struct node
{
int x;
int y;
char z;
} p[100000];
int main()
{
//freopen("in.txt","r",stdin);
int T;
cin>>T;
while(T--)
{
int a,b;
cin>>a>>b;
int N,M;
cin>>N>>M;
for(int i=1; i<=N; i++)
{
cin>>p[i].x>>p[i].y>>p[i].z;
}
int flag=1;
for(int i=0; i<M; i++)
{
int n,r;
char zh;
cin>>n>>zh>>r;
if(flag==0)
continue;
if(zh=='F')
{
for(int j=0; j<r; j++)
{
if(p[n].z=='E')
{p[n].x++;
// cout<<p[n].x;
}
else if(p[n].z=='W')
p[n].x--;
else if(p[n].z=='N')
p[n].y++;
else if(p[n].z=='S')
p[n].y--;
if(p[n].x==0||p[n].y==0||p[n].x==a+1||p[n].y==b+1) //<span id="transmark"></span>
{
cout<<"Robot "<<n<<" crashes into the wall";
flag=0;
break;
}
for(int k=1; k<=N; k++)
{
if(k!=n)
if(p[n].x==p[k].x&&p[n].y==p[k].y)
{
cout<<"Robot "<<n<<" crashes into robot "<<k;
flag=0;
break;
}
}
if(flag==0)
break;
}
}
else if(zh=='L')
{
for(int j=0; j<r; j++)
{
if(p[n].z=='E')
p[n].z='N';
else if(p[n].z=='W')
p[n].z='S';
else if(p[n].z=='N')
p[n].z='W';
else if(p[n].z=='S')
p[n].z='E';
}
}
else if(zh=='R')
{
for(int j=0; j<r; j++)
{
if(p[n].z=='E')
p[n].z='S';
else if(p[n].z=='W')
p[n].z='N';
else if(p[n].z=='N')
p[n].z='E';
else if(p[n].z=='S')
p[n].z='W';
}
}
}
if(flag)
cout<<"OK";
cout<<endl;
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/became_a_wolf/article/details/47380801