0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 17:51:58 +00:00

P1105 平台

R52225346
This commit is contained in:
Baoshuo Ren 2021-06-30 20:28:03 +08:00 committed by Baoshuo Ren
parent f2a72b8e2d
commit c0cc097c32
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

View File

@ -0,0 +1,41 @@
#include <bits/stdc++.h>
using namespace std;
int n, ans[20005];
struct node {
int id, h, l, r;
struct {
int l, r;
} ans;
} a[1005];
bool cmp1(node a, node b) {
return a.h == b.h ? a.id > b.id : a.h < b.h;
}
bool cmp2(node a, node b) {
return a.id < b.id;
}
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
a[i].id = i + 1;
cin >> a[i].h >> a[i].l >> a[i].r;
}
sort(a, a + n, cmp1);
for (int i = 0; i < n; i++) {
a[i].ans.l = ans[a[i].l];
a[i].ans.r = ans[a[i].r];
for (int j = a[i].l + 1; j <= a[i].r - 1; j++) {
ans[j] = a[i].id;
}
}
sort(a, a + n, cmp2);
for (int i = 0; i < n; i++) {
cout << a[i].ans.l << ' ' << a[i].ans.r << endl;
}
return 0;
}