同志!y1是cmath关键字!
by nannuke @ 2022-08-13 09:00:57
@[nannuke](/user/558984)
但他是在局部,没问题。
by xxc123 @ 2023-04-05 18:55:55
```
#include<iostream>
using namespace std;
int main()
{
int east=0,south=0,west=0,north=0;
int x1,y1,x2,y2;
cin>>x1>>y1>>x2>>y2;
int n,s=0;
cin>>n;
for(int i=1;i<=n;i++)
{
char t;
cin>>t;
switch(t)
{
case 'E':east++;break;
case 'S':south++;break;
case 'W':west++;break;
case 'N':north++;break;
}
}
if(x1<=x2)
{
if(y1<=y2)
{
if(x2-x1<=north&&y2-y1<=east)
{
cout<<x2-x1+y2-y1<<endl;
return 0;
}
}
else
{
if(x2-x1<=north&&y1-y2<=west)
{
cout<<x2-x1+y1-y2<<endl;
return 0;
}
}
}
else
{
if(y1<=y2)
{
if(x1-x2<=south&&y2-y1<=east)
{
cout<<x1-x2+y2-y1<<endl;
return 0;
}
}
else
{
if(x1-x2<=south&&y1-y2<=west)
{
cout<<x1-x2+y1-y2<<endl;
return 0;
}
}
}
cout<<-1<<endl;
return 0;
}
by xxc123 @ 2023-04-05 19:28:02