纯暴力过一半
用一个st数组
来判断当前数有没有被用过
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 2e5 + 10;
int a[N];
bool st[N];
int main()
{
int n;
cin >> n;
for(int i = 1; i <= n; i ++)
{
cin >> a[i];
}
int cnt = 0;
while(cnt < n)
{
int last = -1;
for(int i = 1; i <= n; i ++)
{
if(st[i] == false && (last == -1 || a[i] != last) )
{
last = a[i];
st[i] = true;
cout << i <<" ";
cnt ++;
}
}
cout << endl;
}
}