比赛 国庆欢乐赛2 评测结果 MMMMMMTTTTTTTTTTTTTT
题目名称 排列 最终得分 0
用户昵称 29 运行时间 35.394 s
代码语言 C++ 内存使用 490.89 MiB
提交时间 2025-10-04 12:01:00
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000007;
struct t{
    int sef;
    vector<int> child;
};
vector<t> tree; 
int n,a[22]={0},ans=0;
string yz="";
int cl(){
    string zfc=" ";
    for(int i=1;i<=n;i++) zfc+=a[i];
    if(yz.find(zfc)==std::string::npos){
       yz+=zfc; 
       ans++;
    } 
    return 0;
}
int dfs(){
    cl();
    for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j++){
            if(a[i]>a[j]) swap(a[i],a[j]);
            dfs();
        }
    }
    return 0;
}
int main(){
    freopen("changgao_perm.in","r",stdin);
    freopen("changgao_perm.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    dfs();
    cout<<ans<<endl;
}