(比较普通的算法,没有各位dalao的那么……呃,高大上罢
#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int n;
int last=-1;
int tmp;
int main(){
std::ios::sync_with_stdio(0);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
a[i]++;
}
tmp=n;
while(tmp)
{
last=-1;
for(int i=1;i<=n;i++)
{
if(a[i]!=last && a[i]!=0)
{
tmp--;
cout<<i<<" ";
last=a[i];
a[i]=0;
}
else if(a[i]!=0)
{
last=a[i];
}
}
cout<<"\n";
}
return 0;
}