mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 17:56:28 +00:00
P1320 压缩技术(续集版)
R36448319
This commit is contained in:
parent
2ada273bc8
commit
4f5c47bea7
37
problem/P1320/P1320.cpp
Normal file
37
problem/P1320/P1320.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
// R36448319
|
||||
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int n, c; // n: 题意中的N, c: count
|
||||
char l; // 上一个出现的字符
|
||||
string s[205]; // 数组
|
||||
|
||||
n = c = 0;
|
||||
l = '0';
|
||||
|
||||
cin >> s[0];
|
||||
n = s[0].size();
|
||||
for(int i = 1 ; i < n ; i++) {
|
||||
cin >> s[i];
|
||||
}
|
||||
|
||||
cout << n << " ";
|
||||
|
||||
for(int i = 0 ; i < n ; i++) {
|
||||
for(int j = 0 ; j < n ; j++) {
|
||||
if(s[i][j] == l) {
|
||||
c++;
|
||||
} else {
|
||||
cout << c << " "; // 输出以前统计完的
|
||||
c = 1; // 坑点: 这里一定要赋值为1, 因为当前字符也算
|
||||
l = s[i][j]; // 设置当前字符为继续统计对象
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << c << endl; // 坑点: 要输出最后一个统计
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user