88分求助!!!
查看原帖
88分求助!!!
1478271
ytx000楼主2024/10/8 21:01
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n, times = 0;
    cin>>n;
    string str;
    cin>>str;
    for(int i = 0; i < n - 1; i++) {
        if(str[i] == 'V' && str[i + 1] == 'K') {
            times++;
        }
    }
    for(int i = 0; i < n - 1; i++) {
        if(str[i] == 'V' && str[i + 1] != 'K') {
            times++;
            break;
        } else if(str[i + 1] == 'K' && str[i] != 'V') {
            times++;
            break;
        }
    }
    cout<<times;
    return 0;
}

15, 29, 35, 37, 49, 50测试点WA

2024/10/8 21:01
加载中...