QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#66005 | #2374. Cycle String? | gyh20# | WA | 1ms | 5316kb | C++14 | 1.1kb | 2022-12-05 17:22:59 | 2022-12-05 17:23:00 |
Judging History
answer
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
re int t=0;re char v=getchar();
while(v<'0')v=getchar();
while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
return t;
}
const int M=998244353;
inline void add(re int &x,re int y){(x+=y)>=M?x-=M:x;}
inline int Mod(re int x){return x>=M?x-M:x;}
inline int ksm(re int x,re int y){
re int s=1;
while(y){
if(y&1)s=1ll*s*x%M;
x=1ll*x*x%M,y>>=1;
}
return s;
}
int t,n,m,a[1000002],ans,A,B,R[1000002],stk[1000002],tp,num[26];
char s[1000002];
int main(){
scanf("%s",s+1),n=strlen(s+1);
for(re int i=0;i<n;++i)++num[s[i]-'a'];
for(re int i=0;i<26;++i)if(num[i]==n)return puts("NO"),0;
if(n==2)return printf("YES\n%s",s+1),0;
for(re int i=0;i<26;++i)if(num[i]==n-1)return puts("NO"),0;
puts("YES");
for(re int i=0;i<26;++i)if(num[i]>=(n>>1)){
for(re int j=1;j<=(n>>1);++j)putchar(i+'a'),--num[i];
for(re int j=0;j<26;++j)if(j!=i&&num[j]){putchar(j+'a'),--num[j];break;}
while(num[i])putchar(i+'a'),--num[i];
}
for(re int j=0;j<26;++j)while(num[j])putchar(j+'a'),--num[j];
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5316kb
input:
cbbabcacbb
output:
YES aabbbbccc
result:
wrong answer Given string is not a permutation of the input string