QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#352938#7773. 重排ANIG0 52ms13012kbC++231.2kb2024-03-13 18:37:102024-03-13 18:37:11

Judging History

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

  • [2024-03-13 18:37:11]
  • 评测
  • 测评结果:0
  • 用时:52ms
  • 内存:13012kb
  • [2024-03-13 18:37:10]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+5;
string s;
int p[N],n,op,g[N],lst;
signed main(){
    cin>>s;
    n=s.size();
    for(int i=0;i<n;i++)p[s[i]-'a']++;
    for(int i=0;i<26;i++){
        if(p[i]){
            op=i;
            for(int j=i;j<26;j++)p[j-i]=p[j];
            for(int j=26-i;j<26;j++)p[j]=0;
            break;
        }
    }
    cout<<(char)(op+'a');
    p[0]--;lst=0;
    for(int i=2;i<=n;i++){
        for(int j=25;j>=0;j--){
            if(lst&&j>lst)continue;
            if(!p[j])continue;
            g[j]++;p[j]--;
            int mx=1e9;
            for(int k=1;k<26;k++){
                if(!g[k]){
                    mx+=p[k];
                    continue;
                }
                if(p[k]/g[k]>mx)mx+=(p[k]-(g[k]*mx))/(g[k]+1);
                else mx=p[k]/g[k];
            }
           // cout<<i<<" "<<j<<" "<<mx<<endl;
            if(mx<p[0]){
                g[j]--;
                p[j]++;
                continue;
            }
            lst=j;
            if(!j)memset(g,0,sizeof(g));
            cout<<(char)(j+'a'+op);
            break;
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 4ms
memory: 12332kb

input:

mmmmmmmmm

output:

mmmmmmmmm

result:

ok single line: 'mmmmmmmmm'

Test #2:

score: 0
Accepted
time: 1ms
memory: 5728kb

input:

qqymfqgj

output:

fyqqqmjg

result:

ok single line: 'fyqqqmjg'

Test #3:

score: 0
Accepted
time: 0ms
memory: 12372kb

input:

wtzyztttz

output:

tywtztztz

result:

ok single line: 'tywtztztz'

Test #4:

score: 0
Accepted
time: 2ms
memory: 12612kb

input:

bcbccccbcc

output:

bccbccbccc

result:

ok single line: 'bccbccbccc'

Test #5:

score: 0
Accepted
time: 0ms
memory: 12636kb

input:

hojqbzgfb

output:

bqojhgfbz

result:

ok single line: 'bqojhgfbz'

Test #6:

score: 0
Accepted
time: 0ms
memory: 5660kb

input:

rjyrbjqlz

output:

bzyrrqljj

result:

ok single line: 'bzyrrqljj'

Test #7:

score: 0
Accepted
time: 1ms
memory: 5720kb

input:

oiyholvco

output:

cyvooolih

result:

ok single line: 'cyvooolih'

Test #8:

score: 0
Accepted
time: 0ms
memory: 12012kb

input:

ubbnfttog

output:

bttongfbu

result:

ok single line: 'bttongfbu'

Test #9:

score: -10
Wrong Answer
time: 0ms
memory: 12324kb

input:

hhuhttttj

output:

htthttjhu

result:

wrong answer 1st lines differ - expected: 'htthuhttj', found: 'htthttjhu'

Subtask #2:

score: 0
Wrong Answer

Test #16:

score: 20
Accepted
time: 9ms
memory: 11608kb

input:

bbbbbbbcbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

output:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc

result:

ok single line: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc'

Test #17:

score: -20
Wrong Answer
time: 9ms
memory: 13012kb

input:

aaaaaaaabcaabacacaaaacaaabaaaabaabaaaaac

output:

aaaaaaaaaaaaaaaaaaaaabababababacacacacac

result:

wrong answer 1st lines differ - expected: 'aaabaaacaaabaaacaaabaaacaaabaaacaaabaaac', found: 'aaaaaaaaaaaaaaaaaaaaabababababacacacacac'

Subtask #3:

score: 0
Wrong Answer

Test #31:

score: 0
Wrong Answer
time: 52ms
memory: 11524kb

input:

elppjxhjnqephxnnleeepqllpeellqpleexepxlqnpelnlpgplxejlpllppleppnllhjhppgneleghexegqpxpqlqhpnenhlgjjepelllpexplqeppexpqeghpplnpxegeeehqgnhxeqllplphlxpppqnhqephlqnxenlehpeplnqenheejhxqxleeljepehlngepgpxpllppeeheelpplpexpqgheelllplpqnllexlphepghllxnnepqjpqepjeheqqghhejhlnlnlqleeplepxhnlqlnppjpeelqeelxg...

output:

eppppnllllllllllllljjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggeppppnlllllllllllllleppppnlllllllllllllleppppnlllllllllllllleppppnllllllllllllllepp...

result:

wrong answer 1st lines differ - expected: 'eppppnllllllllllllljjjjjjjjjjj...llllllllllleppppnllllllllllllll', found: 'eppppnllllllllllllljjjjjjjjjjj...xexexexexexexexexexexexexexexex'

Subtask #4:

score: 0
Time Limit Exceeded

Test #46:

score: 0
Time Limit Exceeded

input:

ksetiktesataqqwcetteiqcqtwakaiaaaqciceaticteectqqtcaectqtsticctqeqeeiieecaqtctctqqeqitqtttccccctikacktaaqteictwstcitttectaitttiqeqasskkqaateeaatqaetttccesqitiecatgqqaqitwqtaqqcqittittiswcweaiqicqiecwtccakaattgtickccqkqckaaewkekccggtiiqqsttcqactiqeaeqtiigeekettaieekectqqckqqteiceacwecktaiteaceaqkqeic...

output:

atsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccccccccatsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccccccccatsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccccccccatsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccccccccatsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccc...

result: