jzoj100031

版权声明:本博客為本人嘔心瀝血之作,未經允許禁止轉載! https://blog.csdn.net/qq_39529862/article/details/84728762

這題是結論題
好玄學,不懂
代碼:

#include<bits/stdc++.h>
using namespace std;
struct no{
	int v,p;
	bool operator <(const no &rhs)const{
		return v<rhs.v||v==rhs.v&&p<rhs.p;
	}
}c[100010];
int n,a[100010];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		c[i].v=a[i];
		c[i].p=i;
	}
	sort(c+1,c+n+1);
	int x=c[1].p;
	for(int i=1;i<=n;i++){
		printf("%d ",a[x]);
		x=c[x].p;
	}
}

猜你喜欢

转载自blog.csdn.net/qq_39529862/article/details/84728762
今日推荐