Files
python/TangDou/CSP-J/J2-2021/4_Vector.cpp

36 lines
806 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n, cnt;
struct Node {
int id, value;
};
vector<Node> a;
//70分,不能AC
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
int x;
scanf("%d", &x);
a.push_back({i, x});
}
while (cnt < n) {
int flag = 2;
//枚举vector中每个数字,之所以采用迭代器,是因为循环过程中要删除
for (auto it = a.begin(); it != a.end();) {
Node x = *it;
if (x.value != flag) {
flag = x.value;
printf("%d ", x.id);
cnt++;
a.erase(it);
} else
++it;
}
printf("\n");
}
return 0;
}