QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#352983#7773. 重排ANIG0 100ms18240kbC++231.6kb2024-03-13 19:19:072024-03-13 19:19:09

Judging History

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

  • [2024-03-13 19:19:09]
  • 评测
  • 测评结果:0
  • 用时:100ms
  • 内存:18240kb
  • [2024-03-13 19:19:07]
  • 提交

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,rs[N];
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;int lx=0;
    vector<string>q;
    s="";string t="";t+=(char)(op+'a');
    for(int i=2;i<=n;i++){
        for(int j=25;j>=0;j--){
            if(lst&&j>lst)continue;
            if(!p[j])continue;
            if(!j){
                lx=1;lst=0;
                p[0]--;
                q.push_back(s);
                s="";
                s+=(char)('a'+op);
                break;
            }
            if(!lx)g[j]++;
            p[j]--;
            int mx=0;
            if(!lx)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];
            }
            if(mx<p[0]){
                if(!lx)g[j]--;
                p[j]++;
                continue;
            }
            lst=j;
            if(lx)s+=(char)(j+'a'+op);
            else cout<<(char)(j+'a'+op),t+=(char)(j+'a'+op);
            break;
        }
    }
    q.push_back(s);
    while(q.size()&&q.back()==t)cout<<q.back(),q.pop_back();
    for(int i=0;i<q.size();i++)cout<<q[i];
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 10
Accepted
time: 1ms
memory: 7832kb

input:

mmmmmmmmm

output:

mmmmmmmmm

result:

ok single line: 'mmmmmmmmm'

Test #2:

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

input:

qqymfqgj

output:

fyqqqmjg

result:

ok single line: 'fyqqqmjg'

Test #3:

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

input:

wtzyztttz

output:

tywtztztz

result:

ok single line: 'tywtztztz'

Test #4:

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

input:

bcbccccbcc

output:

bccbccbccc

result:

ok single line: 'bccbccbccc'

Test #5:

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

input:

hojqbzgfb

output:

bqojhgfbz

result:

ok single line: 'bqojhgfbz'

Test #6:

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

input:

rjyrbjqlz

output:

bzyrrqljj

result:

ok single line: 'bzyrrqljj'

Test #7:

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

input:

oiyholvco

output:

cyvooolih

result:

ok single line: 'cyvooolih'

Test #8:

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

input:

ubbnfttog

output:

bttongfbu

result:

ok single line: 'bttongfbu'

Test #9:

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

input:

hhuhttttj

output:

htthuhttj

result:

ok single line: 'htthuhttj'

Test #10:

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

input:

rnurrrrkrr

output:

kurrrrrrrn

result:

ok single line: 'kurrrrrrrn'

Test #11:

score: -10
Wrong Answer
time: 1ms
memory: 7536kb

input:

wwwwrrwwrr

output:

rwrwrwwrww

result:

wrong answer 1st lines differ - expected: 'rwrwwrwrww', found: 'rwrwrwwrww'

Subtask #2:

score: 0
Wrong Answer

Test #16:

score: 20
Accepted
time: 1ms
memory: 7656kb

input:

bbbbbbbcbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb

output:

bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc

result:

ok single line: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc'

Test #17:

score: -20
Wrong Answer
time: 1ms
memory: 7692kb

input:

aaaaaaaabcaabacacaaaacaaabaaaabaabaaaaac

output:

aaaaaaaaaaaaaaaaaaaaacacacacacababababab

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #31:

score: 30
Accepted
time: 0ms
memory: 7876kb

input:

elppjxhjnqephxnnleeepqllpeellqpleexepxlqnpelnlpgplxejlpllppleppnllhjhppgneleghexegqpxpqlqhpnenhlgjjepelllpexplqeppexpqeghpplnpxegeeehqgnhxeqllplphlxpppqnhqephlqnxenlehpeplnqenheejhxqxleeljepehlngepgpxpllppeeheelpplpexpqgheelllplpqnllexlphepghllxnnepqjpqepjeheqqghhejhlnlnlqleeplepxhnlqlnppjpeelqeelxg...

output:

eppppnllllllllllllljjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexe...

result:

ok single line: 'eppppnllllllllllllljjjjjjjjjjj...llllllllllleppppnllllllllllllll'

Test #32:

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

input:

vqfiiyoutipohliojhwhyohiqholfovovhwvuffvifvlffiuwhphmoofjyhhjtfimiisjqwwjtvlotmpivlvyoilvwhhygofhvffoiftmyhpvjqypqfoihfhfjisoiwjujuqvijofilwqjjmqfymtiivfoplifwjplvfvfqvstlihfotqjfylowttwsyvsifvfhptpfovqilvujfyltohvmjtijhpiyffpvyiioyvjqpfjhshowphuttflpfojiovhvtiwfymfvwyooftimyumoomosjlitviowfhtoovlov...

output:

fwvvuuuuuuuttttttttttttttttttttttttttttssssssssssssssssssssqqqqqqqqqqqqqqqqqqqqqqqqqqqppppppppppppppppppppppppppppppppppppppppppppppoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooommmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmllllllllllllllllllll...

result:

ok single line: 'fwvvuuuuuuuttttttttttttttttttt...uuttttttttttttttttttttttttttttt'

Test #33:

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

input:

hdkfjdurfkufuqjhfrhodhrqqsjjaduooafqrkfjhufjqfuqqjhryrahhyggkorjqfjraohrfrqkfjjqarkdfryrooyuoffuqfyyfhdjmhghumjojuafkdrqmohrahhyaaouqfjjojgjrykrhduoshqahquhhoqahokgkfhaojhkjkukafqqrdrsyfqahuqhqduqqufujohjgauoarjagfaaamjuqoqhqkrouuoryhhqyodjfqgjhykhryorguqkoffuyaqgoqodjragfrgkyojmodkuhyjyffuyyjajfhrf...

output:

aurrrqqqqqqqqqqqqoooooooooooooooooooooooooooooooooooooooooooommmmmmmmmmmmmmmmmmkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhggg...

result:

ok single line: 'aurrrqqqqqqqqqqqqooooooooooooo...ooooooooooooooooooooooooooooooo'

Test #34:

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

input:

uksbcbnccbkuqbtebuykgybzbzzbgtznktgzgutckyxbetckqbzzybfybqtykskkccgzskutkqgzyygszkeqgyecbkzbgckktshzgzkbkbztbybgtnntzyezbgtkzgncqkctxegbztzyyggnbyybbuykghsxegkekxhsuynkzyxbzxkcnksezeyejgnytegsyzcgkkyygbxstgytkyeuuzzktknzkeuksnkzgckbzcnegnbkzkzzgzqjzgyshyeeggnceggcyhctqscftbtczcbtyzyskcyyezyyfekyfcgb...

output:

bzyttsssssssssssssssssssssssssssqqqqqqqqqqqqqqqqqqqnnnnnnnnnnnnnnnnnnnnnnkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkjjjhhhhhhhhgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggfffffffffff...

result:

ok single line: 'bzyttsssssssssssssssssssssssss...qqqqqqqqnnnnnnnnnnnnnnnnnnnnnnn'

Test #35:

score: -30
Wrong Answer
time: 0ms
memory: 7692kb

input:

hhhccchhhcchhhcchccchcchccccchcchhchhchcchhhcchcccchhcchchccchhccccccchccccchhchcchcccchchhcchchccccchhhccccchhhchccchhccccchhchhccchccchchccccchhhccccchhcchchhchchchcchcchhhccccccccccchhhhcchchhcchhhhcchchcchcccchcchcccchchcccchcccchhhhccchcccchccccchhhcchcchchhccchchhhchcchcchcccchcchccchhccchhchc...

output:

ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchchch...

result:

wrong answer 1st lines differ - expected: 'cchcchchcchchcchchcchchcchchcc...hcchchcchchcchchcchchcchchcchch', found: 'cccccccccccccccccccccccccccccc...hchchchchchchchchchchchchchchch'

Subtask #4:

score: 0
Wrong Answer

Test #46:

score: 0
Wrong Answer
time: 100ms
memory: 18240kb

input:

ksetiktesataqqwcetteiqcqtwakaiaaaqciceaticteectqqtcaectqtsticctqeqeeiieecaqtctctqqeqitqtttccccctikacktaaqteictwstcitttectaitttiqeqasskkqaateeaatqaetttccesqitiecatgqqaqitwqtaqqcqittittiswcweaiqicqiecwtccakaattgtickccqkqckaaewkekccggtiiqqsttcqactiqeaeqtiigeekettaieekectqqckqqteiceacwecktaiteaceaqkqeic...

output:

atsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccccccccatsqqqkiiiiiiiigggeeeeeeeeecccccccccccccccccccccawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawa...

result:

wrong answer 1st lines differ - expected: 'atsqqqkiiiiiiiiiggggeeeeeeeeee...eeecccccccccccccccccccccccccccc', found: 'atsqqqkiiiiiiiiiggggeeeeeeeeee...eeecccccccccccccccccccccccccccc'