ninininininini @ 2024-07-14 10:30:11
大佬帮忙看一下,样例过了,提交只过了两个数据点,想不通哪里错了
#include <iostream>
using namespace std;
int main() {
string str_ans = "", str_temp, str_start;
cin >> str_start;
int n = str_start.length();
str_ans += str_start;
for (int i = 1; i < n; i++) {
cin >> str_temp;
str_ans += str_temp;
}
// cout << str_ans << endl;
int pos = 1; // 从第二位开始读取
int ans[40005] = {0};
ans[1] = 1;
int Pos = 1; // 从第二位开始计数
while (pos <= str_ans.length()) {
if (str_ans[pos] == str_ans[pos - 1]) {
ans[Pos] += 1;
} else {
ans[Pos + 1] += 1;
Pos += 1;
}
pos += 1;
}
cout << n << " ";
for (int i = 1; i < Pos; i++) {
cout<< ans[i] << " ";
}
return 0;
}