QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#558864 | #8829. Aibohphobia | Amanicus# | WA | 0ms | 3776kb | C++14 | 1.3kb | 2024-09-11 18:56:48 | 2024-09-11 18:56:49 |
Judging History
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;
}
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 s="";
while(ff<=2){
for(char i='a';i<='z';i++){
if(mp[i]>=1){
ss+=s[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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3488kb
input:
5 a sos abba icpc tenet
output:
YES a YES oss NO YES picc YES nteet
result:
ok Correct (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3776kb
input:
18 qnx oooo tvttj zzzzz pvlne iijt hjhjj loo hh uq mgvgv ewwe iii kykk o mmumm aetvv xntl
output:
YES xqn NO YES vtttj YES RR YES vplne YES tiij YES RR
result:
wrong answer Not a permutation (test case 4)