模板 - 算法基础 - 离线询问
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);
}