You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
970 B

#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
//普通队列,应该是因为每个数字进入队列不只一次,所以导致队列资源用尽,需要启用循环队列
// 60% TLE 4个点
struct Node {
int id, v;
};
int n;
int hhq, ttq = -1;
int hhp, ttp = -1;
Node q[N], p[N];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
int x;
scanf("%d", &x);
q[++ttq] = {i, x};
}
int cnt = 0;
while (cnt < n) {
int flag = 2;
while (hhq <= ttq) {
auto a = q[hhq];
hhq++;
if (a.v != flag) {
printf("%d ", a.id);
flag = a.v;
cnt++;
} else
p[++ttp] = a;
}
puts("");
while (hhp <= ttp) {
auto a = p[hhp];
q[++ttq] = a;
hhp++;
}
}
return 0;
}