QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#557168 | #7773. 重排 | Sorting | 10 | 59ms | 87808kb | C++20 | 1.6kb | 2024-09-11 07:32:36 | 2024-09-11 07:32:36 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
string s;
int n;
string best;
int cnt;
deque<pair<string,bool> >sub;
void solve(){//entropy = len(best) + sum(sizes in sub)
/*cout << best << ' ' << cnt << endl;
for(auto d:sub){
cout << d.fi << ' ' << d.se << endl;
}
cout << endl;*/
if(sub.empty()){
for(int i=0; i<cnt ;i++) cout << best;
return;
}
int ss=sub.size();
int rep=(cnt-1)/ss;
int frog=cnt-rep*ss;
string sex,rb;
for(int i=0; i<rep ;i++) sex+=best;
reverse(sex.begin(),sex.end());
string magic=sub[frog-1].fi;
reverse(magic.begin(),magic.end());
int ncnt=1;
for(int i=0; i<frog ;i++){
if(sub[frog-i-1].se) ++ncnt;
else break;
}
if(ncnt!=frog){
rb=best;
reverse(rb.begin(),rb.end());
}
for(int i=0; i<frog-ncnt ;i++){
sub.push_back({sub[0].fi+sex+rb,sub[0].se});
}
for(int i=0; i<frog ;i++) sub.pop_front();
sub[0].se=false;
if(rep==0){
best+=magic;
cnt=ncnt;
solve();return;
}
for(int i=0; i<ss-frog ;i++){
sub[i].fi+=sex;
}
if(ss-frog<sub.size()) sub[ss-frog].se=false;
string nbest;
for(int i=0; i<rep+1 ;i++) nbest+=best;
nbest+=magic;
best=nbest;
cnt=ncnt;
solve();
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);
cin >> s;n=s.size();
sort(s.begin(),s.end());
char mn=s[0];
reverse(s.begin(),s.end());
for(auto c:s){
if(c==mn) ++cnt;
else{
string t=(string)""+c;
bool frog=(!sub.empty() && sub.back().fi==t);
sub.push_back({t,frog});
}
}
best="";best+=mn;
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 3616kb
input:
mmmmmmmmm
output:
mmmmmmmmm
result:
ok single line: 'mmmmmmmmm'
Test #2:
score: 10
Accepted
time: 0ms
memory: 3492kb
input:
qqymfqgj
output:
fyqqqmjg
result:
ok single line: 'fyqqqmjg'
Test #3:
score: 10
Accepted
time: 0ms
memory: 3624kb
input:
wtzyztttz
output:
tywtztztz
result:
ok single line: 'tywtztztz'
Test #4:
score: 10
Accepted
time: 0ms
memory: 3544kb
input:
bcbccccbcc
output:
bccbccbccc
result:
ok single line: 'bccbccbccc'
Test #5:
score: 10
Accepted
time: 0ms
memory: 3552kb
input:
hojqbzgfb
output:
bqojhgfbz
result:
ok single line: 'bqojhgfbz'
Test #6:
score: 10
Accepted
time: 0ms
memory: 3500kb
input:
rjyrbjqlz
output:
bzyrrqljj
result:
ok single line: 'bzyrrqljj'
Test #7:
score: 10
Accepted
time: 0ms
memory: 3608kb
input:
oiyholvco
output:
cyvooolih
result:
ok single line: 'cyvooolih'
Test #8:
score: 10
Accepted
time: 0ms
memory: 3548kb
input:
ubbnfttog
output:
bttongfbu
result:
ok single line: 'bttongfbu'
Test #9:
score: 10
Accepted
time: 0ms
memory: 3828kb
input:
hhuhttttj
output:
htthuhttj
result:
ok single line: 'htthuhttj'
Test #10:
score: 10
Accepted
time: 0ms
memory: 3600kb
input:
rnurrrrkrr
output:
kurrrrrrrn
result:
ok single line: 'kurrrrrrrn'
Test #11:
score: 10
Accepted
time: 0ms
memory: 3596kb
input:
wwwwrrwwrr
output:
rwrwwrwrww
result:
ok single line: 'rwrwwrwrww'
Test #12:
score: 10
Accepted
time: 0ms
memory: 3616kb
input:
tppvcjlls
output:
cvtsppllj
result:
ok single line: 'cvtsppllj'
Test #13:
score: 10
Accepted
time: 0ms
memory: 3492kb
input:
fyrrwriyxr
output:
fyyxwrrrri
result:
ok single line: 'fyyxwrrrri'
Test #14:
score: 10
Accepted
time: 0ms
memory: 3832kb
input:
ouulnlasnu
output:
auuusonnll
result:
ok single line: 'auuusonnll'
Test #15:
score: 10
Accepted
time: 0ms
memory: 3540kb
input:
aasapssss
output:
aspassass
result:
ok single line: 'aspassass'
Subtask #2:
score: 0
Wrong Answer
Test #16:
score: 20
Accepted
time: 0ms
memory: 3824kb
input:
bbbbbbbcbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
output:
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc
result:
ok single line: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc'
Test #17:
score: 20
Accepted
time: 0ms
memory: 3792kb
input:
aaaaaaaabcaabacacaaaacaaabaaaabaabaaaaac
output:
aaabaaacaaabaaacaaabaaacaaabaaacaaabaaac
result:
ok single line: 'aaabaaacaaabaaacaaabaaacaaabaaacaaabaaac'
Test #18:
score: 20
Accepted
time: 0ms
memory: 3820kb
input:
abbcbbbabbacbbbbabcbbbabbbcbabbbababbaabbbb
output:
abbbbacacacacabbbbbabbbbbabbbbbabbbbbabbbbb
result:
ok single line: 'abbbbacacacacabbbbbabbbbbabbbbbabbbbbabbbbb'
Test #19:
score: 20
Accepted
time: 0ms
memory: 3824kb
input:
baaaabaaaaabaaaaaaaaabaaaaaaaaabaaabbaaaaaaaaabaa
output:
aaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaab
result:
ok single line: 'aaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaabaaaaab'
Test #20:
score: 20
Accepted
time: 0ms
memory: 3604kb
input:
aaabbaaaaaaabbaaaaaaabaaaaaaabaaaaaaaabbbaaaaaa
output:
aaaaabaaaabaaaabaaaabaaaaabaaaabaaaabaaaabaaaab
result:
ok single line: 'aaaaabaaaabaaaabaaaabaaaaabaaaabaaaabaaaabaaaab'
Test #21:
score: 20
Accepted
time: 0ms
memory: 3536kb
input:
bcccbcaababccbcbbccbacbbcabcbbbbacbccaabccaccb
output:
accbbaccbbaccbbbaccbbaccbbaccbbbaccbbaccbbaccc
result:
ok single line: 'accbbaccbbaccbbbaccbbaccbbaccbbbaccbbaccbbaccc'
Test #22:
score: 0
Wrong Answer
time: 0ms
memory: 3840kb
input:
caaaacacacaaacacccaaacacaacaaccbcacbaaccccbcaaac
output:
abacacacacacacacacacacacacacacacacacacacabacabac
result:
wrong answer 1st lines differ - expected: 'abacacacacacacacabacacacacacacacabacacacacacacac', found: 'abacacacacacacacacacacacacacacacacacacacabacabac'
Subtask #3:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 0ms
memory: 3796kb
input:
elppjxhjnqephxnnleeepqllpeellqpleexepxlqnpelnlpgplxejlpllppleppnllhjhppgneleghexegqpxpqlqhpnenhlgjjepelllpexplqeppexpqeghpplnpxegeeehqgnhxeqllplphlxpppqnhqephlqnxenlehpeplnqenheejhxqxleeljepehlngepgpxpllppeeheelpplpexpqgheelllplpqnllexlphepghllxnnepqjpqepjeheqqghhejhlnlnlqleeplepxhnlqlnppjpeelqeelxg...
output:
eppppnllllllllllllljjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexexe...
result:
wrong answer 1st lines differ - expected: 'eppppnllllllllllllljjjjjjjjjjj...llllllllllleppppnllllllllllllll', found: 'eppppnllllllllllllljjjjjjjjjjj...llllllllllleppppnllllllllllllll'
Subtask #4:
score: 0
Wrong Answer
Test #46:
score: 0
Wrong Answer
time: 59ms
memory: 87808kb
input:
ksetiktesataqqwcetteiqcqtwakaiaaaqciceaticteectqqtcaectqtsticctqeqeeiieecaqtctctqqeqitqtttccccctikacktaaqteictwstcitttectaitttiqeqasskkqaateeaatqaetttccesqitiecatgqqaqitwqtaqqcqittittiswcweaiqicqiecwtccakaattgtickccqkqckaaewkekccggtiiqqsttcqactiqeaeqtiigeekettaieekectqqckqqteiceacwecktaiteaceaqkqeic...
output:
atsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccccccccawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawawa...
result:
wrong answer 1st lines differ - expected: 'atsqqqkiiiiiiiiiggggeeeeeeeeee...eeecccccccccccccccccccccccccccc', found: 'atsqqqkiiiiiiiiiggggeeeeeeeeee...eeecccccccccccccccccccccccccccc'