QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#558872#8829. AibohphobiaAmanicus#WA 0ms3564kbC++141.3kb2024-09-11 19:02:182024-09-11 19:02:19

Judging History

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

  • [2024-09-11 19:02:19]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3564kb
  • [2024-09-11 19:02:18]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define llt __int128_t
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 1e2+10;
const int M = 1e6 + 7;
const int MAX = 0x3f3f3f3f;
const ll maxn = 1e18;
ll h,s1,vv,u,mi,mx,fz,fm,ans,item,f;
ll m,n,x,y,x2,y2,z,z2,d,gcd,l,r,k,T,p,cnt;
ll sum;
ll c[M],dp[N][N];
string s,ss,s3,s2;
ll a[N][N];
map<char,ll>mp;
void solve() {
	mp.clear();
	cin>>s;
	f=0;
	n=s.size();
	if(n==1){
		cout<<"YES"<<"\n";
		cout<<s<<"\n";
		return;
	}
	for(ll i=0;i<n;i++){
		mp[s[i]]++;
	}
	char cc;
	for(char i='a';i<='z';i++){
		if(mp[i]==1){
			f=1;
			cc=i;
			break;
		}
		else if(mp[i]>=2){
			cnt++;
		}
	}
	if(f){
		cout<<"YES"<<"\n";
		string ss="";
		ss+=cc;
		for(ll i=0;i<n;i++){
			if(s[i]!=cc){
				ss+=s[i];
			}
		}
		cout<<ss<<"\n";
		return;
	}
	if(cnt>2){
		f=1;
	}
	if(f){
		cout<<"YES"<<"\n";
		ll ff=1;
		string ss="";
		while(ff<=2){
			for(char i='a';i<='z';i++){
				if(mp[i]>=1){
					ss+=i;
					mp[i]--;
				}
			}
			ff++;
		}
		for(ll i=0;i<n;i++){
			if(mp[s[i]]>=1){
				ss+=s[i];
				mp[s[i]]--;
			}
		}
		cout<<ss<<"\n";
		return;
	}
	else{
		cout<<"NO"<<"\n";
	}
}
int main() {
	IOS;
	T=1;
	cin>>T;
	while(T--) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
a
sos
abba
icpc
tenet

output:

YES
a
YES
oss
NO
YES
icpc
YES
nteet

result:

ok Correct (5 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3564kb

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
epvln
YES
jiit
YES
hjhjj
YES
loo
YES
hh
YES
qu
YES
mgvgv
YES
ewew
YES
iii
YES
ykkk
YES
o
YES
ummmm
YES
aetvv
YES
lxnt

result:

wrong answer Some prefix is a palindrome (test case 7)