QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#694570#8829. AibohphobiaIllusionaryWhiteTraveler#WA 1ms3784kbC++14892b2024-10-31 18:13:162024-10-31 18:13:16

Judging History

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

  • [2024-10-31 18:13:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3784kb
  • [2024-10-31 18:13:16]
  • 提交

answer

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
void Solve(){
	string s;
	cin>>s;
	int ct[26];
	for(int i=0;i<26;i++){
		ct[i]=0;
	}
	for(auto C:s){
		ct[C-'a']++;
	}
	vector<pair<int,char>>A;
	for(int i=0;i<26;i++){
		if(ct[i]!=0){
			A.push_back(make_pair(ct[i],'a'+i));
		}
	}
	sort(A.begin(),A.end());
	if(A.size()<3){
		if(A[0].first==1){
			cout<<"YES\n"<<A[0].second;
			if(A.size()==2){
				for(int i=A[1].first;i>0;i--){
					cout<<A[1].second;
				}
			}
			cout<<"\n";
		}else{
			puts("No");
		}
	}else{
		cout<<"Yes\n"<<A[0].second;
		int b=A.size();
		for(int i=1;i<b;i++){
			for(int j=A[i].first;j>0;j--){
				cout<<A[i].second;
			}
		}
		for(int i=A[0].first;i>1;i--){
			cout<<A[0].first;
		}
		cout<<'\n';
	}
}
int main(){
	int t;
	cin>>t;
	for(int i=0;i<t;i++){
		Solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3784kb

input:

5
a
sos
abba
icpc
tenet

output:

YES
a
YES
oss
No
Yes
ipcc
Yes
neett

result:

ok Correct (5 test cases)

Test #2:

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

input:

18
qnx
oooo
tvttj
zzzzz
pvlne
iijt
hjhjj
loo
hh
uq
mgvgv
ewwe
iii
kykk
o
mmumm
aetvv
xntl

output:

Yes
nqx
No
Yes
jvttt
No
Yes
elnpv
Yes
jtii
No
YES
loo
No
YES
qu
Yes
mggvv
No
No
YES
ykkk
YES
o
YES
ummmm
Yes
aetvv
Yes
lntx

result:

ok Correct (18 test cases)

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3596kb

input:

138
gcseqpht
brrrzsrerr
ree
lgryyyh
wbxkwwwwx
hsihaga
kvvslzgv
dssd
qhrqqqrqyh
dfffffsfgf
ssuzuuzzs
rrwnyrcdnb
ealelecu
ccfwwwccwc
emeieme
xeexeswes
ymkkkkpkk
eimderoz
lflllh
lluylcll
rquqrqu
mllmllll
cscscc
ssssssssss
cn
llljlzlzj
h
kbbxahczit
yxrrrrxlkr
uikiakika
tntnnqntw
sjhxyfsy
fcyyyf
dbvbvdbw...

output:

Yes
ceghpqst
Yes
beszrrrrrr
YES
ree
Yes
ghlryyy
Yes
bkxxwwwww
Yes
gisaahh
Yes
gklszvvv
No
Yes
yhhrrqqqqq
Yes
dgsfffffff
Yes
suuuzzz33
Yes
bcdwynnrrr
Yes
aculleee
Yes
fwwwwccccc
Yes
immeeee
Yes
wssxxeeee
Yes
mpykkkkkk
Yes
dimorzee
Yes
fhllll
Yes
cuylllll
Yes
ruuqqq2
No
No
No
YES
cn
Yes
jzzlllll2
YES
...

result:

wrong answer Not a permutation (test case 11)