3Luby3 @ 2024-09-28 19:17:41
#include<bits/stdc++.h>
#define int long long
using namespace std;
string s;
char c[1001][1001];
int cnt,flag;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>s;
for(int i=0;i<s.size();i++){
int j=1;
c[j][i+1]=s[i];
}
for(int i=2;i<=s.size();i++){
for(int j=1;j<=s.size();j++){
cin>>c[i][j];
}
}
cout<<s.size()<<" ";
if(c[1][1]!='0') flag=1;
for(int i=1;i<=s.size();i++){
for(int j=1;j<=s.size();j++){
if(flag==1){
if(c[i][j]=='1') cnt++;
else{
cout<<cnt<<" ";
cnt=1;
flag=0;
}
}else{
if(c[i][j]=='0') cnt++;
else{
cout<<cnt<<" ";
cnt=1;
flag=1;
}
}
}
}
cout<<cnt;
return 0;
}
/*
0001000
0001000
0001111
0001000
0001000
0001000
1111111
*/
by jinshengzhe @ 2024-09-28 20:02:52
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n";
int cnt, len, flag, fl;
string s, x;
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
while(cin >> x)
s += x;
len = s.size();
cout << sqrt(len) << " ";
if(s[0] == '0')
cnt++;
else
fl = 1;
for(int i = 1; i < len; i++){
if(flag == 1)
{
if(fl == 1)
{
cnt++;
fl = 0;
}
if(s[i] == '1')
cnt++;
else
{
cout << cnt << " ";
cnt = 1;
flag = 0;
}
}
else
{
if(s[i] == '0')
cnt++;
else
{
cout << cnt << " ";
cnt = 1;
flag = 1;
}
}
}
cout << cnt << endl;
return 0;
}
自己再想想