提交时间:2023-08-25 15:22:30
运行 ID: 100389
#include <bits/stdc++.h> #define endl '\n' using namespace std; int n; const int N = 1005; int h[N],l[N],r[N]; int ans1,ans2; int tmp1,tmp2; signed main() { cin >> n; for(int i = 1; i <= n; i++) { cin >> h[i] >> l[i] >> r[i]; } h[0] = -1; l[0] = -0x3f3f3f3f; r[0] = 0x3f3f3f3f; for(int i = 1; i <= n; i++) { tmp1 = tmp2 = -0x3f3f3f3f; for(int j = 0; j <= n; j++) { if(h[j]<h[i]&&l[j]<l[i]&&l[i]<=r[j]) { if(h[j]>tmp1) { ans1 = j; tmp1 = h[j]; } } } for(int j = 0; j <= n; j++) { if(h[j]<h[i]&&r[j]>r[i]&&r[i]>=l[j]) { if(h[j]>tmp2) { ans2=j; tmp2=h[j]; } } } cout << ans1 << " " << ans2 << endl; } return 0; }