10pts 求助

P1042 [NOIP2003 普及组] 乒乓球

saruo233 @ 2024-07-13 16:20:20

#include <iostream>
const int N = 65000;
char s[N], n;
void read() {
    char c = getchar();
    while (c != 'E') {
        if (c == ' ' || c == '\n') {
            c = getchar();
            continue;
        }
        s[++n] = c;
        c = getchar();
    }
}
void f(int score) {
    for (int i = 1, l = 0, r = 0; i <= n; i++) {
        if (s[i] == 'W')    ++l;
        else ++r;
        if (std::abs(l - r) >= 2 && (l >= score || r >= score)) {
//          std::cout << l << ':' << r << std::endl;
            printf("%d:%d\n", l, r);
            l = 0, r = 0;
        }
        if (i == n) {
//          std::cout << l << ':' << r << std::endl;
            printf("%d:%d\n", l, r);
            l = 0, r = 0;
            continue;
        }
    }
}

int main() {
    read();
    f(11);
//  std::cout << std::endl;
    printf("\n");
    f(21);
    return 0;
}
只有10分,两个WA,其他都是RE

by saruo233 @ 2024-07-13 16:21:18

https://www.luogu.com.cn/record/165740509

这是记录


|