Punny @ 2021-08-05 08:53:42
#include<bits/stdc++.h>
using namespace std;
char a,b[40001];
int n,x,t,ans_0,ans_1;
int main(){
while(a=getchar()){
b[++x]=a;
if(b[x]=='\n'){
x--;
n=x;
break;
}
}
while(a=getchar()){
b[++x]=a;
if(b[x]=='\n') x--;
if(x==n*n) break;
}
printf("%d ",n);
int i=1;
while(i<=n*n){
if(b[i]=='0') ans_0++;
else ans_1++;
if(!t&&b[i]=='1'){
printf("%d ",ans_0);
ans_0=0;
t=1;
}else if(t&&b[i]=='0'){
printf("%d ",ans_1);
ans_1=0;
t=0;
}
i++;
}
if(t) printf("%d ",ans_1);
else printf("%d ",ans_0);
return 0;
}
/*
输入:
0001000
0001000
0001111
0001000
0001000
0001000
1111111
本地输出:7 3 1 6 1 6 4 3 1 6 1 6 1 3 7
洛谷输出:8 3 1 6 2 6 6 3 1 6 2 6 2 3 17
by Punny @ 2021-08-05 08:54:10
感觉应该是输入出了问题
by 庄nnnn额 @ 2021-08-11 20:33:56
同感同感(我怀疑洛谷在每个输入前面都垫上了个字符)