首页 > 代码库 > 繁华模拟赛 Evensgn玩序列

繁华模拟赛 Evensgn玩序列

技术分享

技术分享

#include<iostream>#include<cstdio>#include<string>#include<cstring>#include<algorithm>using namespace std;const int maxn = 5000;int n,a[maxn],b[maxn],c[maxn],rka[maxn],rkb[maxn],rkc[maxn];bool visa[maxn],visb[maxn],visc[maxn];int rk,rec;int main(){    freopen("perm.in","r",stdin);    freopen("perm.out","w",stdout);    ios::sync_with_stdio(false);    cin>>n;    for(int i = n;i >= 1;i--){        cin>>a[i];        visa[a[i]] = true;    }    for(int i = n;i >= 1;i--){        cin>>b[i];        visb[b[i]] = true;    }    for(int i = n;i >= 1;i--){        rk = -1;        for(int j = 0;j <= a[i];j++) if(visa[j]) rk++;        visa[a[i]] = false;        rka[i] = rk;    }    for(int i = n;i >= 1;i--){        rk = -1;        for(int j = 0;j <= b[i];j++) if(visb[j])rk++;        visb[b[i]] = false;        rkb[i] = rk;    }    for(int i = 1;i <= n;i++){        rkc[i] += rka[i] + rkb[i];        rkc[i+1] += rkc[i] / i;        rkc[i] %= i;    }    memset(visc,true,sizeof(visc));    for(int i = n;i >= 1;i--){        rec = rk = 0;        while(1){            if(visc[rec]) rk++;            if(rk > rkc[i]) break;            rec++;        }        visc[rec] = false;        cout<<rec<<" ";    }    return 0;}

 

繁华模拟赛 Evensgn玩序列