D1T1 wa 求调
  • 板块学术版
  • 楼主HAuCl4
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/4/2 14:58
  • 上次更新2023/10/23 19:38:37
查看原帖
D1T1 wa 求调
289304
HAuCl4楼主2023/4/2 14:58
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=200005;
struct node{
	int l,r;
	bool operator <(const node& p) const{
		return l<p.l;
	}
}in[N],a[N];
bool cmpl(node a,node b)
{
	return a.l<b.l;
}
bool cmpr(node a,node b)
{
	return a.r>b.r;
}
int n,m,x;
bool ok[N];
void mian()
{
	ok[x]=1;
	sort(a+1,a+m+1,cmpr);
	int id=1;
	for(int u=x;u>=1;u--)
	{
		if(!ok[u]) continue;
		while(id<=m && a[id].r>=u)
		{
			if(a[id].l<u) ok[a[id].l]=1;
			++id;
		}
	}
	for(int u=1;u<=x-1;u++)
		if(ok[u]) printf("%d ",u);
	sort(a+1,a+m+1,cmpl);
	id=1;
	for(int u=x;u<=n;u++)
	{
		if(!ok[u]) continue;
		while(id<=m && a[id].l<=u)
		{
			if(a[id].r>u) ok[a[id].r]=1;
			++id;
		}
	}
	for(int u=x+1;u<=n;u++)
		if(ok[u]) printf("%d ",u);
}

int main()
{
	scanf("%d%d%d",&n,&m,&x);
	for(int i=1;i<=m;i++) scanf("%d%d",&a[i].l,&a[i].r);
	mian();
	return 0;
}
2023/4/2 14:58
加载中...