for (int i = 1; i <= n; i++)
{
cin >> a[i].val;
a[i].pos = i;
}
for (int i = 1; i <= n; i++)
{
cin >> b[i].val;
b[i].pos = i;
}
sort(a + 1, a + 1 + n, cmp);
sort(b + 1, b + 1 + n, cmp);
for (int i = 1; i <= n; i++)
{
c[a[i].pos] = b[i].pos;
}
结构体的离散化
for (int i = 1; i <= n; i++)
{
cin >> a[i];
x[i] = a[i];
}
sort(x + 1, x + 1 +n);
for (int i = 1; i <= n; i++)
{
a[i] = lower_bound(x + 1, x + 1 + n, a[i]) - x;
}
for (int i = 1; i <= n; i++)
{
cin >> b[i];
x[i] = b[i];
}
sort(x + 1, x + 1 +n);
for (int i = 1; i <= n; i++)
{
b[i] = lower_bound(x + 1, x + 1 + n, b[i]) - x;
}
for (int i = 1; i <= n; i++)
{
c[a[i]] = b[i];
}
普通的离散化 用上面的写ac了,用下面的写只有10pts,其他代码一点没动,这是为什么