小生真没招了(哭
我的代码:
#include<bits/stdc++.h>
using namespace std;
int main() {
int n, cnt = 0;
bool used = false;
cin >> n;
char last = ' ', current = ' ';
getchar();
for (int i = 0; i < n; i++) {
current = getchar();
if (last == 'V' && current == 'K') {
cnt++;
last = ' ';
} else if (last == ' ') {
last = current;
} else {
last = current;
if (!used) {
cnt++;
used = true;
last = ' ';
}
}
}
getchar();
cout << cnt;
return 0;
}
交上去62pts
第四个样例错了 我下载下来:
输入:
20
VKKKKKKKKKVVVVVVVVVK
输出:
3
我在本地跑了一边 过了???
但洛谷读出来是 1
我真服了 感觉是被做局了
求帮本蒟蒻解读
一眨眼就开学了 早知道就不眨眼了