QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#203944#87. Devil's ShareAhmed57#Compile Error//C++233.3kb2023-10-06 22:34:442024-07-04 02:17:05

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 02:17:05]
  • 评测
  • [2023-10-06 22:34:44]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int arr[5];string s;
string maa;string w;int k,x;
string lol[4*4*4*4][13];
void rec(){
    bool ss = 0;
    for(int i = 1;i<=4;i++){
        if(arr[i]){
            ss = 1;
            arr[i]--;s+=char(i+'0');
            rec();
            arr[i]++;
            s.pop_back();
        }
    }
    if(ss==0){
        string ma;
        for(int j = 0;j<s.size()-k+1;j++){
            string se;
            for(int e = j;e<j+k;e++)se+=s[e];
            if(ma.empty())ma = se;
            ma = max(ma,se);
        }
        if(maa.empty()||ma<maa){
            maa = ma;
            w = s;
        }
    }
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int k;cin>>k;
    if(k==4){
    for(int t = 1;t<4*4*4*4;t++){
        int de = 0;
        int e = t;
        int sum = 0;
        for(int i = 1;i<=4;i++){
            arr[i] = e%4;
            e/=4;
            sum+=arr[i];
        }for(int K = 1;K<=sum;K++){
        k = K;
        maa = "";
        rec();
        lol[t][k] = w;
        }
    }
    int t;cin>>t;
    for(int z = 0;z<t;z++){
        if(z)cin>>k;
        if(k==2){
            int arr[10] = {0};
        for(int i = 1;i<10;i++)cin>>arr[i];
        if(k<2){
            for(int i = 1;i<10;i++){
                for(int j = 0;j<arr[i];j++){
                    cout<<char(i+'0');
                }
            }
            cout<<endl;
        }else{
            int su = 0;
            string v;int ind = 0;
            for(int i = 9;i>=1;i--){
                su+=arr[i];
                if(su>=2){
                    su-=arr[i];
                    ind = i;break;
                }else{
                    for(int j = 0;j<arr[i];j++){
                        v+=char(i+'0');
                    }
                    arr[i] = 0;
                }
            }
            if(su==1){
                int lol = 1;
                while(arr[ind]){
                    while(arr[lol]==0)lol++;
                    v+=char(lol+'0');
                    arr[lol]--;
                    if(arr[ind]){
                        v+=char(ind+'0');
                        arr[ind]--;
                    }
                }
                for(int i = 1;i<10;i++){
                    for(int j = 0;j<arr[i];j++){
                        v+=char(i+'0');
                    }
                }
            }else{
                int lol = 1;
                while(arr[ind]){
                    if(arr[ind]){
                        v+=char(ind+'0');
                        arr[ind]--;
                    }
                    while(lol<10&&arr[lol]==0)lol++;
                    if(lol<10){
                    v+=char(lol+'0');
                    arr[lol]--;
                    }
                }
                for(int i = 1;i<10;i++){
                    for(int j = 0;j<arr[i];j++){
                        v+=char(i+'0');
                    }
                }
            }
            reverse(v.begin(),v.end());
        cout<<v<<endl;
        }
        }
        int de = 0;
        for(int i = 1;i<=4;i++){
            cin>>arr[i];
        }
        for(int i = 5;i<10;i++)cin>>x;
        for(int i = 4;i>=1;i--){de*=4;de+=arr[i];}
        cout<<lol[de][k]<<endl;
    }
    }
}

Details

cc1plus: fatal error: answer.code: No such file or directory
compilation terminated.