Files
python/TangDou/CSP-J/J2-2021/4_Vector.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

36 lines
806 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}