This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
struct Node {
int id, v;
};
int n;
queue<Node> q, p;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
int x;
scanf("%d", &x);
q.push({i, x});
}
int cnt = 0;
while (cnt < n) {
int last = 2; //每一轮,首位都需要输出,所以这里的 flag需要每次初始化为2,黄海最初将它放在while的外面,调试了近半个小时~
while (q.size()) {
auto a = q.front();
q.pop();
if (a.v != last) {
printf("%d ", a.id);
last = a.v;
cnt++;
} else
p.push(a);
puts("");
while (p.size()) {
auto a = p.front();
q.push(a);
p.pop();
return 0;