0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-14 02:58:47 +00:00
OI-codes/Luogu/P1320/P1320.cpp

38 lines
851 B
C++
Raw Normal View History

// R36448319
#include <bits/stdc++.h>
using namespace std;
int main() {
2021-11-19 09:01:13 +00:00
int n, c; // n: 题意中的N, c: count
char l; // 上一个出现的字符
string s[205]; // 数组
n = c = 0;
l = '0';
cin >> s[0];
n = s[0].size();
2021-11-19 09:01:13 +00:00
for (int i = 1; i < n; i++) {
cin >> s[i];
}
cout << n << " ";
2021-11-19 09:01:13 +00:00
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (s[i][j] == l) {
c++;
} else {
2021-11-19 09:01:13 +00:00
cout << c << " "; // 输出以前统计完的
c = 1; // 坑点: 这里一定要赋值为1, 因为当前字符也算
l = s[i][j]; // 设置当前字符为继续统计对象
}
}
}
2021-11-19 09:01:13 +00:00
cout << c << endl; // 坑点: 要输出最后一个统计
return 0;
}