P2632
模拟写晕了.主要是开始没仔细看题..把方向什么的都搞错了...
不管怎么说..总算调试出来了..1ac
#include
<
iostream
>
#include < string >
using namespace std;
int casek;
char errorStr[ 500 ];
int error1,error2;
int main()
{
cin>>casek;
while(casek--)
{
int a,b;
int n,m;
cin>>a>>b;
cin>>n>>m;
int x[101],y[101];
char f[101];
for (int i=1;i<=n;i++)
{
cin>>x[i]>>y[i]>>f[i];
}
bool crash=false;
for (int i=1;i<=m;i++)
{
int u,step;
char ch;
cin>>u>>ch>>step;
if (crash) continue;
switch(ch)
{
case 'L':
for (int j=1;j<=step;j++)
{
switch(f[u])
{
case 'W':f[u]='S';break;
case 'S':f[u]='E';break;
case 'E':f[u]='N';break;
case 'N':f[u]='W';break;
default:break;
}
}
break;
case 'R':
for (int j=1;j<=step;j++)
{
switch(f[u])
{
case 'W':f[u]='N';break;
case 'N':f[u]='E';break;
case 'E':f[u]='S';break;
case 'S':f[u]='W';break;
default:break;
}
}
break;
case 'F':
int xx=x[u],yy=y[u];
for (int j=1;j<=step;j++)
{
switch(f[u])
{
case 'W':xx--;break;
case 'N':yy++;break;
case 'E':xx++;break;
case 'S':yy--;break;
default:break;
}
if (xx<1||yy<1||xx>a||yy>b) {cout<<"Robot "<<u<<" crashes into the wall"<<endl;crash=true;break;}
for (int k=1;k<=n;k++)
{
if (k==u) continue;
if (xx==x[k]&&yy==y[k]) {cout<<"Robot "<<u<<" crashes into robot "<<k<<endl;crash=true;break;}
}
if (crash) break;
}
// cout<<xx<<" "<<yy<<" "<<u<<endl;
x[u]=xx;
y[u]=yy;
break;
}
}
if (!crash)
{
cout<<"OK"<<endl;
}
}
return 0;
}
#include < string >
using namespace std;
int casek;
char errorStr[ 500 ];
int error1,error2;
int main()
{
cin>>casek;
while(casek--)
{
int a,b;
int n,m;
cin>>a>>b;
cin>>n>>m;
int x[101],y[101];
char f[101];
for (int i=1;i<=n;i++)
{
cin>>x[i]>>y[i]>>f[i];
}
bool crash=false;
for (int i=1;i<=m;i++)
{
int u,step;
char ch;
cin>>u>>ch>>step;
if (crash) continue;
switch(ch)
{
case 'L':
for (int j=1;j<=step;j++)
{
switch(f[u])
{
case 'W':f[u]='S';break;
case 'S':f[u]='E';break;
case 'E':f[u]='N';break;
case 'N':f[u]='W';break;
default:break;
}
}
break;
case 'R':
for (int j=1;j<=step;j++)
{
switch(f[u])
{
case 'W':f[u]='N';break;
case 'N':f[u]='E';break;
case 'E':f[u]='S';break;
case 'S':f[u]='W';break;
default:break;
}
}
break;
case 'F':
int xx=x[u],yy=y[u];
for (int j=1;j<=step;j++)
{
switch(f[u])
{
case 'W':xx--;break;
case 'N':yy++;break;
case 'E':xx++;break;
case 'S':yy--;break;
default:break;
}
if (xx<1||yy<1||xx>a||yy>b) {cout<<"Robot "<<u<<" crashes into the wall"<<endl;crash=true;break;}
for (int k=1;k<=n;k++)
{
if (k==u) continue;
if (xx==x[k]&&yy==y[k]) {cout<<"Robot "<<u<<" crashes into robot "<<k<<endl;crash=true;break;}
}
if (crash) break;
}
// cout<<xx<<" "<<yy<<" "<<u<<endl;
x[u]=xx;
y[u]=yy;
break;
}
}
if (!crash)
{
cout<<"OK"<<endl;
}
}
return 0;
}