#include
using namespace std;
const int N = 1000010;
int p[N], a[N];
int find(int x) {
if (x != p[x]) p[x] = find(p[x]);
return p[x];
}
int main(void) {
int n;
scanf("%d", &n);
for (int i = 1; i <= N; i++) p[i] = i;
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
for (int i = 1; i <= n; i++) {
int father = find(a[i]);
printf("%d ", father);
p[father] = father + 1;
}
return 0;
}
0.0分
1 人评分
完数 (C语言代码)浏览:760 |
用筛法求之N内的素数。 (C语言代码)浏览:711 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:1483 |
DNA (C语言代码)浏览:798 |
蓝桥杯历届试题-翻硬币 (C++代码)浏览:955 |
程序员的表白 (C语言代码)浏览:678 |
Quadratic Equation (C语言代码)浏览:1035 |
整数平均值 (C语言代码)浏览:856 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:609 |
C二级辅导-统计字符 (C语言代码)浏览:697 |