时间复杂度超过99.87%
2025-10-27 22:30:49
发布于:北京
1阅读
0回复
0点赞
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAX_DATA_SIZE = 2501 * 25 + 10; // 最大可能数据量(2501行×25字符)
char data[MAX_DATA_SIZE]; // 比赛数据
int data_len = 0; // 实际长度
// 处理target_score赛制
void process(int target_score) {
int hua = 0, opp = 0; // 华华得分和对手得分
for (int i = 0; i < data_len; i++) {
if (data[i] == 'W') hua++;
else opp++;
// !检查!
if (max(hua, opp) >= target_score && abs(hua - opp) >= 2) {
printf("%d:%d\n", hua, opp);
hua = 0; // 重置比分
opp = 0;
}
}
// !!!输出未完成局
printf("%d:%d\n", hua, opp);
}
int main() {
char c;
// 输入,直到遇到E
while (scanf("%c", &c) == 1) {
if (c == 'E') break;
if (c == 'W' || c == 'L') {
data[data_len++] = c;
}
}
// 11分
process(11);
printf("\n");
// 21分
process(21);
return 0;
}
这里空空如也




有帮助,赞一个