QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#457692 | #8829. Aibohphobia | ucup-team4074# | WA | 0ms | 3712kb | C++20 | 1.3kb | 2024-06-29 13:40:35 | 2024-06-29 13:40:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
void solve();
using pii = pair<int, int>;
using db = double;
signed main(){
fast
int t = 1;
cin >> t;
for(int i = 1; i <= t; i++){
solve();
}
}
const int N = 3e5 + 10, M = N * 2, P = 998244353;
int b[35];
string ss;
void solve(){
cin>>ss;
if(ss.size()==1)
{
cout<<"YES"<<'\n';
cout<<ss<<'\n';
return;
}
memset(b,0,sizeof(b));
for(int i=0;i<ss.size();i++)
{
b[(int)(ss[i]-'a')]++;
}
stable_sort(ss.begin(),ss.end());
int minalp(0),cnt(0);
for(int i=0;i<25;i++)
{
if(b[i])
{
minalp=i;
break;
}
}
for(int i=0;i<25;i++)
{
if(b[i])
{
if(b[minalp]>b[i])minalp=i;
cnt++;
}
}
// cout<<ss<<'\n';
if(b[minalp]==1)
{
cout<<"YES"<<'\n';
int head(0);
for(int i=0;i<ss.size();i++)
{
if(ss[i]==(char)(minalp+'a'))
{head=i;break;}
}
cout<<(char)(minalp+'a');
ss.erase(ss.begin()+head,ss.begin()+head+1);
cout<<ss<<'\n';
}
else
{
if(cnt>=3)
{
cout<<"YES"<<'\n';
int head(0);
while(ss[head]==ss[0])head++;
ss.erase(ss.begin()+1,ss.begin()+head);
cout<<ss;
for(int i=1;i<head;i++)cout<<ss[0];
cout<<'\n';
}
else cout<<"NO"<<'\n';
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
5 a sos abba icpc tenet
output:
YES a YES oss NO YES iccp YES neett
result:
ok Correct (5 test cases)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3712kb
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 jtttv NO YES elnpv YES jiit 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: 0ms
memory: 3660kb
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 berrrrrrsz YES ree YES ghlryyy YES bkwwwwwxx YES gaahhis YES gklsvvvz NO YES yhhqqqqqrr YES dfffffffgs NO YES bcdnnrrrwy YES aceeellu YES fcccccwwww YES ieeeemm YES weeeessxx YES mkkkkkkpy YES deeimorz YES fhllll YES cllllluy YES qrruuqq NO NO NO YES cn NO YES h YES abbchiktxz YES k...
result:
wrong answer Jury found the answer but participant didn't (test case 11)