分析
代码
#include <cstdio>
const int N = 1100010;
int p[N];
int find(int x)
{
if (p[x] != x) p[x] = find(p[x]);
return p[x];
}
int main()
{
int n;
scanf("%d", &n);
for (int i = 1; i < N; i ++ ) p[i] = i;
for (int i = 1; i <= n; i ++ )
{
int x;
scanf("%d", &x);
x = find(x);
printf("%d ", x);
p[x] = x + 1;
}
return 0;
}
nb呀
tql
orzorzorz
tql
orz
6
图片看不了
6
tql!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
%%%
tql
很强!!!
赞