跳到正文

个人记录

猴排

Danny_F61约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2025年12月12日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
#define int long long
#define lbt(x) x&(-x)

using namespace std;
const int inf=0x3f3f3f3f3f3f3f3f,p=998244353;
void solve() {}
vector<int>a;
signed main() {
//  freopen("text.in","r",stdin);
//  freopen("text.out","w",stdout);
	cin.tie(0)->sync_with_stdio(false);
	cout.tie(0);
	unsigned seed = chrono::system_clock::now().time_since_epoch().count();
	default_random_engine rng(seed);
	int n;cin>>n;
	for(int i=1;i<=n;++i) {
		int x;cin>>x;
		a.push_back(x);
	}
	while(prev_permutation(a.begin(),a.end())) {
		shuffle(a.begin(),a.end(),rng);
	}
	next_permutation(a.begin(),a.end());
	for(auto t:a)cout<<t<<" ";
	return 0;
}

当然,随机数生成我搜了一下

原文