50分,10个WA,10个AC,怎么改?
查看原帖
50分,10个WA,10个AC,怎么改?
575803
wangzicheng2009楼主2022/7/9 11:07
#include<bits/stdc++.h>
using namespace std;
unsigned long long i, t, s, x, y, m, n;
char a[2000000000];
int main() {
	std::ios::sync_with_stdio(false);
	cin >> a >> t;
	s = strlen(a);
	for (i; i < t; i++) {
		if ((i >= s) && (i + s - 1 < t)) {
			x += m;
			y += n;
			i += s - 1;
			continue;
		} else if (i > s - 1) {
			a[i] = a[i % s];
		} else if (a[i] == 'N') {
			y++;
		} else if (a[i] == 'S') {
			y--;
		} else if (a[i] == 'W') {
			x--;
		} else if (a[i] == 'E') {
			x++;
		}
		m = x;
		n = y;
	}
	cout << x << " " << y;
	return 0;
}
2022/7/9 11:07
加载中...