求助!!!
查看原帖
求助!!!
694295
yuanbingtao楼主2022/6/6 11:26
#include <iostream>
#include <cmath>

using namespace std;

const int s[] = { 11, 21 };

int a[25 * 2500 + 10], n;
char c;

int main() {
	while (1) {
		cin >> c;
		if (c == 'E') {
			break;
		}
		else if (c == 'W') {
			a[n++] = 1;
		}
		else {
			a[n++] = 0;
		}
	}
	for (int i = 0; i < 2; i++) {
		int w = 0, f = 0;
		for (int j = 0; j < n; j++) {
			w += a[i], f += 1 - a[i];
			if (max(w, f) >= s[i] && abs(w - f) >= 2) {
				cout << w << ":" << f << endl;
				w = f = 0;
			}
		}
		cout << w << ": " << f << endl << endl;
	}
	return 0;
}

样例过了但只见WA一片

2022/6/6 11:26
加载中...