QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#203948#87. Devil's ShareAhmed57#0 1ms3644kbC++233.3kb2023-10-06 22:39:482024-07-04 02:17:06

Judging History

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

  • [2024-07-04 02:17:06]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3644kb
  • [2023-10-06 22:39:48]
  • 提交

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 t;cin>>t;
    int a;cin>>a;
    if(a>2){
    for(int q = 1;q<4*4*4*4;q++){
        int de = 0;
        int e = q;
        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[q][k] = w;
        }
    }
    k = a;
    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

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

1536
4
2 1 2 2 0 0 0 0 0
2
3 2 3 3 0 0 0 0 0
3
1 2 0 3 0 0 0 0 0
4
2 2 3 2 0 0 0 0 0
1
3 3 2 2 0 0 0 0 0
3
1 2 2 0 0 0 0 0 0
3
2 1 2 3 0 0 0 0 0
6
1 3 3 0 0 0 0 0 0
4
1 0 1 2 0 0 0 0 0
4
2 1 2 3 0 0 0 0 0
4
2 3 0 2 0 0 0 0 0
5
3 2 3 3 0 0 0 0 0
3
2 2 1 1 0 0 0 0 0
3
2 3 2 0 0 0 0 0 0
8
1 3 1 3 0 0 0...

output:


result:


Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 3644kb

input:

35960
2
0 0 5 2 0 0 17 0 7
2
0 6 0 15 0 0 0 4 5
2
3 0 0 1 20 0 0 0 8
2
0 5 0 0 15 0 5 7 0
2
0 0 2 11 0 0 4 0 10
2
0 14 0 0 11 0 0 6 1
2
0 0 10 3 0 0 8 0 1
2
0 1 9 0 2 0 0 6 0
2
0 0 0 0 5 0 12 7 3
2
0 0 5 0 0 2 0 8 9
2
7 2 0 0 0 0 0 6 8
2
0 0 0 4 1 0 3 18 0
2
0 0 14 4 8 0 0 0 1
2
0 2 0 0 0 13 3 9 0
2...

output:


result:

wrong output format Unexpected end of file - token expected

Subtask #3:

score: 0
Time Limit Exceeded

Test #11:

score: 0
Time Limit Exceeded

input:

26488
21
7 19 0 0 0 0 0 0 0
3
15 21 0 0 0 0 0 0 0
7
4 35 0 0 0 0 0 0 0
5
28 12 0 0 0 0 0 0 0
22
40 3 0 0 0 0 0 0 0
1
7 6 0 0 0 0 0 0 0
5
12 21 0 0 0 0 0 0 0
18
27 13 0 0 0 0 0 0 0
2
36 6 0 0 0 0 0 0 0
15
19 14 0 0 0 0 0 0 0
34
17 20 0 0 0 0 0 0 0
11
17 5 0 0 0 0 0 0 0
19
10 12 0 0 0 0 0 0 0
28
29 9 ...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%