QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#558779#8829. Aibohphobiaknightofshadow#WA 0ms3532kbC++141.1kb2024-09-11 18:30:352024-09-11 18:30:35

Judging History

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

  • [2024-09-11 18:30:35]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3532kb
  • [2024-09-11 18:30:35]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	string s;
	while(n--){
		map<ll,ll>a;
		cin>>s;
		ll cnt=0;
		s='-'+s;
		for(int i=1;i<=s.size()-1;i++){
			a[s[i]-'a']++;
			if(a[s[i]-'a']==1) cnt++;
		}
		if(cnt==1){
			if(s.size()==2) {
				cout<<"Yes\n";
				for(auto it:a)cout<<static_cast<char>(it.first+'a')<<'\n';
			}
			else{
				cout<<"No\n";
			}
		}
		else if(cnt==2){
			if(s.size()<=4){
				cout<<"Yes\n";
				char b,c;
				ll f=0,cc;
				for(auto it:a){
					if(f==0&&it.second==1){
						f=1;
						b=static_cast<char>(it.first+'a');
					}
					else {
						c=static_cast<char>(it.first+'a');
						cc=it.second;
					}
				}
				cout<<b;
				for(int i=1;i<=cc;i++) cout<<c;
				cout<<'\n';
			}
			else cout<<"No\n";
		}
		else{
			cout<<"Yes\n";
			for(auto it:a){
				cout<<static_cast<char>(it.first+'a');
			}
			for(auto it:a){
				for(int i=2;i<=it.second;i++) cout<<static_cast<char>(it.first+'a');
			}
			cout<<'\n';
		}
	} 
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
a
sos
abba
icpc
tenet

output:

Yes
a
Yes
oss
No
Yes
cipc
Yes
entet

result:

ok Correct (5 test cases)

Test #2:

score: -100
Wrong Answer
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
jtvtt
No
Yes
elnpv
Yes
ijti
No
Yes
loo
No
Yes
qu
Yes
gmvgv
No
No
No
Yes
o
No
Yes
aetvv
Yes
lntx

result:

wrong answer Jury found the answer but participant didn't (test case 14)