struct Query {
    int id, pos, ans;
} q[200005];
bool cmp1(const Query &q1, const Query &q2) {
    return q1.pos < q2.pos;
}
bool cmp2(const Query &q1, const Query &q2) {
    return q1.id < q2.id;
}
void InputQuery(int n) {
    for(int i = 1; i <= n; ++i) {
        scanf("%d", &q[i].pos);
        q[i].id = i;
    }
    sort(q + 1, q + 1 + n, cmp1);
}
void OutputQuery(int n) {
    sort(q + 1, q + 1 + n, cmp2);
//    for(int i = 1; i <= n; ++i)
//        printf("%d%c", q[i].ans, " \n"[i == n]);
    for(int i = 1; i <= n; ++i)
        printf("%d\n", q[i].ans);
}原文:https://www.cnblogs.com/KisekiPurin2019/p/11925193.html