10分 求调
查看原帖
10分 求调
572133
潘德理2010楼主2023/10/2 23:39

没有看出来哪里错了,但交上去只有10分,是思路错了吗 :

#include<bits/stdc++.h>
using namespace std;
int n,m,t[111111];
struct st{
	int l,r;
}d[111111];
bool cmp(st a,st b){
	return a.r>b.r;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d%d",&d[i].l,&d[i].r);
	for(int i=1;i<=n;i++) t[i]=i;
	sort(d+1,d+m+1,cmp);
	for(int i=1;i<=m;i++) t[d[i].l]=max(t[d[i].l],t[d[i].r]);
	for(int i=1;i<=n;i++) printf("%d ",t[i]);
	return 0;
}
2023/10/2 23:39
加载中...