1504A Déjà Vu codeforces solution in cpp
by ujjal roy
#include<bits/stdc++.h>
using namespace std;
int palim(string x,int si)
{
for(int i=0;i<si;i++)
{
if(x[i]!=x[si-i-1]) return 1;
}
return 0;
}
main()
{
int t,n,i,c;
cin>>t;
while(t--)
{
c=0;
string s;
string m="a";
cin>>s;
m+=s;
int r=palim(m,m.size());
if(r==1)
{
cout<<"YES"<<endl;
cout<<m<<endl;
c=1;
}
if(c==0)
{
m='a';
m=s+m;
r=palim(m,m.size());
if(r==1)
{
cout<<"YES"<<endl;
cout<<m<<endl;
c=1;
}
else cout<<"NO"<<endl;
}
}
return 0;
}
0 Comments