神奇
  • 板块P1105 平台
  • 楼主CreeperXLX
  • 当前回复3
  • 已保存回复3
  • 发布时间2022/1/20 21:08
  • 上次更新2023/10/28 11:44:19
查看原帖
神奇
300049
CreeperXLX楼主2022/1/20 21:08
#include<bits/stdc++.h>
using namespace std;
struct platform{
    int h,l,r;
};
int main (){
    int N;
    cin>>N;
    platform p[N];
    for(int i=1;i<=N;i++){
        cin>>p[i].h>>p[i].l>>p[i].r;
    }
    for(int i=1;i<=N;i++){
        int left=0,right=0;
        for(int j=1;j<=N;j++){
            if(p[j].h<p[i].h&&p[j].l<p[i].l&&p[j].r>p[i].l){
                if(p[left].h<p[j].h)left=j;
            }
        }
        cout<<left<<" ";
        for(int j=1;j<=N;j++){
            if(p[j].h<p[i].h&&p[j].l<p[i].r&&p[j].r>p[i].r){
                if(p[right].h<p[j].h)right=j;
            }
        }
        cout<<right<<endl;
    }
    return 0;
}

以上代码提交WA得80 但把结构体改成这样就对了

struct platform{
    int h=0,l=0,r=0;
};

不解

2022/1/20 21:08
加载中...