比赛 国庆欢乐赛2 评测结果 AAAATTTTATTTTTTTTTTT
题目名称 排列 最终得分 25
用户昵称 对立猫猫对立 运行时间 31.282 s
代码语言 C++ 内存使用 22.55 MiB
提交时间 2025-10-04 11:57:09
显示代码纯文本
#include <bits/stdc++.h>
#define For(i, a, b) for(register int i = a; i <= b; i++)
using namespace std;
int n, ans, a[25];
set<string> zt;
bool judge() {
	string s = "";
	For(i, 1, n) s += (char)(a[i] + '0');
	if (zt.find(s) == zt.end()) {
		ans++;
		zt.insert(s);
		return true;
	}
	return false;
}
void moni() {
	if (!judge()) return;
	For(i, 1, n) For(j, i + 1, n) if (a[i] > a[j]) swap(a[i], a[j]), moni(), swap(a[i], a[j]);
	return;
}
int main() {
	freopen("changgao_perm.in", "r", stdin);
	freopen("changgao_perm.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> n;
	For(i, 1, n) cin >> a[i];
	moni();
	cout << ans << endl;
	return 0;
}