QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#66005#2374. Cycle String?gyh20#WA 1ms5316kbC++141.1kb2022-12-05 17:22:592022-12-05 17:23:00

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-05 17:23:00]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5316kb
  • [2022-12-05 17:22:59]
  • 提交

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