输出跟测试数据一样却爆0?
查看原帖
输出跟测试数据一样却爆0?
1023568
zhr1219楼主2023/8/30 09:43

本蒟蒻下载了测试样例自测没有问题,但在评测机上却爆 00。QAQ

代码:

#include<bits/stdc++.h>
using namespace std;
string a;int t,x,y;
int stx,sty;
void walk(char ch){
	if(ch=='E')x++;
	if(ch=='S')y--;
	if(ch=='W')x--;
	if(ch=='N')y++;
}
int main(){
	getline(cin,a);cin>>t;
	for(int i=0;i<a.size();i++){
		walk(a[i]);
		if(i==t%(a.size())-1)stx=x,sty=y;
	}
	int yyy=t/a.size();
	cout<<x*yyy+stx<<" "<<y*yyy+sty;  
	return 0;
}
2023/8/30 09:43
加载中...