社区讨论

怎么不对啊

P2689东南西北参与者 2已保存回复 1

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
1 条
当前快照
1 份
快照标识符
@mhk6xabs
此快照首次捕获于
2025/11/04 14:31
4 个月前
此快照最后确认于
2025/11/04 14:31
4 个月前
查看原帖
CPP
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d,e,x,y,x2,y2;
char f;
bool xtf,ytf,xans,yans;
int main()
{
	cin>>a>>b>>c>>d>>e;
	x = b-a;
	y = d-c;
	if(x>=0)xtf = 1;
	if(y>=0)ytf = 1;
	for(int i=1;i<=e;i++){
	cin>>f;
	if(xtf&&f=='E')x2++;
	if(!xtf&&f=='W')x2--;
	if(ytf&&f=='N')y2++;
	if(!ytf&&f=='S')y2--;
	}
	if((xtf&&x2>x)||(!xtf&&x2<x))xans = 1;
	if((ytf&&y2>y)||(!ytf&&y2<y))yans = 1;
	if(xans&&yans)cout<<x+y;
	else cout<<-1;
	return 0;
}
只有40分

回复

1 条回复,欢迎继续交流。

正在加载回复...