20260412
///source code (X) sauce code (O)
/// 아몬드 맛있다
#include <stdio.h>
#include <stdlib.h>
int map [30][30]= {};
int queue[50][50]= {};
int a=0,cnt=0,f=0,l=0,dong[500],sort[500],visited[100],px=0,python=0;
void push (int qwe,int rty)
{
queue[1][l]=qwe;
queue[2][l]=rty;
l++;
return;
}
void pop ()
{
if (f>0)
{
return ;
}
/// int qwertyuiop,asdfghjkl;
px=queue[1][f];
python=queue[2][f];
return;
}
int cmp(int *pa,int *pb)
{
if (*pa>*pb)
return 1;
else
return -1;
}
int bfs(int x,int y)
{
int now;
map [x][y]=0;
dong[cnt]+=1;
while (f<l)
{
for (int i=0; i<=a; i++)
{
if (map[now][i]==1&&visited[i]==0)
{
push (now,i);
pop();
bfs(px,python);
}
}
}
}
int main ()
{
///과거의 나 주석좀 달아라
int i,j;
scanf("%d",&a);
for (i=0; i<a; i++)
{
for (j=0; j<a; j++)
{
scanf("%1d",&map[i][j]);
}
}
for (i=0; i<a; i++)
{
for (j=0; j<a; j++)
{
if (map[i][j]==1)
{
bfs (i,j);
cnt++;
printf("CNT:%d \n",cnt);
}
}
}
for (i=0; i<cnt; i++)
{
sort[i]=dong[i];
}
qsort(&queue[f-1][f-1],cnt,sizeof(int),cmp);
printf("%d\n",cnt);
for(i=0; i<cnt; i++)
{
printf("%d\n",sort[i]);
}
return 0x0444;
}

