QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#269751 | #7773. 重排 | zhouhuanyi | 0 | 54ms | 32596kb | C++23 | 1.4kb | 2023-11-29 22:36:09 | 2023-11-29 22:36:10 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<vector>
#define N 1000000
using namespace std;
int read()
{
char c=0;
int sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
int n,cnt[26];
char c[N+1];
string s;
vector<char>p[N+1];
int main()
{
int ps=0,d,pst,dst=0,dwt;
cin>>s,n=s.length();
for (int i=1;i<=n;++i) cnt[s[i-1]-'a']++;
for (int i=0;i<26;++i)
if (cnt[i])
{
ps=i;
break;
}
if (cnt[ps]==n)
{
cout<<s<<endl;
return 0;
}
d=min(cnt[ps],n-cnt[ps]),pst=1;
for (int i=1;i<=cnt[ps];++i) p[pst].push_back((char)('a'+ps)),pst=pst%d+1;
cnt[ps]=0;
if (d!=1)
{
pst=ps+1,dst=d;
for (int i=2;i<=d;++i)
if (p[i].size()!=p[1].size())
{
dst=i-1;
while (!cnt[pst]) pst++;
p[i].push_back((char)('a'+pst)),cnt[pst]--;
}
pst=25;
while (1)
{
for (int i=dst;i>=1;--i)
{
while (pst!=-1&&!cnt[pst]) pst--;
if (pst!=-1) p[i].push_back((char)('a'+pst)),cnt[pst]--;
}
if (pst==-1) break;
dwt=0;
for (int i=1;i<=dst;++i)
if (p[i].back()==p[1].back())
dwt=i;
dst=dwt;
}
}
else
{
for (int i=25;i>=ps+1;--i)
for (int j=1;j<=cnt[i];++j)
p[1].push_back((char)('a'+i));
}
for (int i=1;i<=d;++i)
for (int j=0;j<p[i].size();++j)
printf("%c",p[i][j]);
puts("");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 0ms
memory: 26932kb
input:
mmmmmmmmm
output:
mmmmmmmmm
result:
ok single line: 'mmmmmmmmm'
Test #2:
score: 0
Accepted
time: 2ms
memory: 27060kb
input:
qqymfqgj
output:
fyqqqmjg
result:
ok single line: 'fyqqqmjg'
Test #3:
score: 0
Accepted
time: 0ms
memory: 27972kb
input:
wtzyztttz
output:
tywtztztz
result:
ok single line: 'tywtztztz'
Test #4:
score: 0
Accepted
time: 6ms
memory: 27040kb
input:
bcbccccbcc
output:
bccbccbccc
result:
ok single line: 'bccbccbccc'
Test #5:
score: 0
Accepted
time: 5ms
memory: 27056kb
input:
hojqbzgfb
output:
bqojhgfbz
result:
ok single line: 'bqojhgfbz'
Test #6:
score: 0
Accepted
time: 0ms
memory: 27136kb
input:
rjyrbjqlz
output:
bzyrrqljj
result:
ok single line: 'bzyrrqljj'
Test #7:
score: 0
Accepted
time: 3ms
memory: 27628kb
input:
oiyholvco
output:
cyvooolih
result:
ok single line: 'cyvooolih'
Test #8:
score: 0
Accepted
time: 0ms
memory: 27172kb
input:
ubbnfttog
output:
bttongfbu
result:
ok single line: 'bttongfbu'
Test #9:
score: -10
Wrong Answer
time: 0ms
memory: 27064kb
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: 5ms
memory: 27136kb
input:
bbbbbbbcbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
output:
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc
result:
ok single line: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc'
Test #17:
score: -20
Wrong Answer
time: 0ms
memory: 27276kb
input:
aaaaaaaabcaabacacaaaacaaabaaaabaabaaaaac
output:
aaabaaabaaabaaabaaabaaacaaacaaacaaacaaac
result:
wrong answer 1st lines differ - expected: 'aaabaaacaaabaaacaaabaaacaaabaaacaaabaaac', found: 'aaabaaabaaabaaabaaabaaacaaacaaacaaacaaac'
Subtask #3:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 0ms
memory: 27112kb
input:
elppjxhjnqephxnnleeepqllpeellqpleexepxlqnpelnlpgplxejlpllppleppnllhjhppgneleghexegqpxpqlqhpnenhlgjjepelllpexplqeppexpqeghpplnpxegeeehqgnhxeqllplphlxpppqnhqephlqnxenlehpeplnqenheejhxqxleeljepehlngepgpxpllppeeheelpplpexpqgheelllplpqnllexlphepghllxnnepqjpqepjeheqqghhejhlnlnlqleeplepxhnlqlnppjpeelqeelxg...
output:
eppppnllllllllllllljjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhgggggggggggggggggggggggggggggggggggggggggggggggggggggggggggeppppnlllllllllllllleppppnlllllllllllllleppppnlllllllllllllleppppnllllllllllllllepp...
result:
wrong answer 1st lines differ - expected: 'eppppnllllllllllllljjjjjjjjjjj...llllllllllleppppnllllllllllllll', found: 'eppppnllllllllllllljjjjjjjjjjj...xexexexexexexexexexexexexexexex'
Subtask #4:
score: 0
Wrong Answer
Test #46:
score: 0
Wrong Answer
time: 54ms
memory: 32596kb
input:
ksetiktesataqqwcetteiqcqtwakaiaaaqciceaticteectqqtcaectqtsticctqeqeeiieecaqtctctqqeqitqtttccccctikacktaaqteictwstcitttectaitttiqeqasskkqaateeaatqaetttccesqitiecatgqqaqitwqtaqqcqittittiswcweaiqicqiecwtccakaattgtickccqkqckaaewkekccggtiiqqsttcqactiqeaeqtiigeekettaieekectqqckqqteiceacwecktaiteaceaqkqeic...
output:
atsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccccccccatsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccccccccatsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccccccccatsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccccccccatsqqqkiiiiiiiiiggggeeeeeeeeeeeeeecccccccccccccccccccccc...
result:
wrong answer 1st lines differ - expected: 'atsqqqkiiiiiiiiiggggeeeeeeeeee...eeecccccccccccccccccccccccccccc', found: 'atsqqqkiiiiiiiiiggggeeeeeeeeee...wawawawawawawawawawawawawawawaw'