P2434 WA 0pts求调
查看原帖
P2434 WA 0pts求调
577429
LYRT_Subway楼主2024/2/20 22:09

WA 0pts求调

#include <iostream>
#include<algorithm>
using namespace std;
int n;
struct node{
    int L,R;
    bool operator<(node const other)const{
        if(R!=other.R) return R<other.R;
        else return L<other.L;
    }
}a[50240];
int main(){
    cin>>n;
    for(int i=0;i<n;i++) {
        cin >> a[i].L >> a[i].R;
    }
    sort(a,a+n);
	/*
	cout<<endl;
    for(int i=0;i<n;i++)
    {
    	cout<<a[i].L<<" "<<a[i].R<<endl;
	}
	cout<<endl;
    */
	for(int i=0;i<n;i++)
    {
    	if(a[i-1].R<a[i].L or i==0)
    	{
    		cout<<a[i].L<<" ";
		}
		if(a[i+1].L>a[i].R or i==n-1)
		{
			cout<<a[i].R<<endl;
		}
	}
    return 0;
}
2024/2/20 22:09
加载中...