提交时间:2023-12-20 13:53:05

运行 ID: 116903

#include<bits/stdc++.h> #define endl '\n' using namespace std; const int N=1005; int h[N],l[N],r[N],n,ans1,ans2,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; }