T了2个点
#include<bits/stdc++.h>
using namespace std;
int n;
struct p
{
int a,b,c,s;
};
queue<p> q;
long long ans;
int Prev = -1;
int sum;
int st = 1;
int main()
{
scanf("%d",&n);
for(int i = 1;i <= n;i ++)
{
int x;
scanf("%d",&x);
if(x != Prev && i > 1)
{
q.push({sum,0,Prev,st});
sum = 0;
st = i;
}
Prev = x;
sum ++;
}
q.push({sum,0,Prev,st});
while(!q.empty())
{
p PRev = {0,0,-1,0};
int P = -1;
int i = q.size();
while(i)
{
i --;
// cout << PRev.c << " " << q.front().c << endl;
if(PRev.c == q.front().c)
{
P = q.front().s + q.front().a;
q.push(q.front());
q.pop();
continue;
}
PRev = q.front();
int PP = q.front().s + q.front().b;
if(PP < P) puts(""),PRev = {0,0,-1,0};
printf("%d ",q.front().s + q.front().b);
if(q.front().b < q.front().a - 1)
{
q.push({q.front().a,q.front().b + 1,q.front().c,q.front().s});
}
q.pop();
P = PP;
}
puts("");
}
return 0;
}