Skip to main content

educational codeforces round 56(B. Letters Rearranging)

 

Problem solving criteria:Just check palindrome or not
Palindrome:a word, phrase, or sequence that reads the same backwards as forwards.
checking palindrome:revserse a string then checking it is equal to the previous string.
rev=str;
reverse(rev.begin(),rev.end());
if(rev==str) print(palindrome)

///Bismillahir Rahmanir Rahim
///Author: Tanvir Ahmmad
///CSE,Islamic University,Bangladesh

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<vector>
#include<iterator>
#include <functional> ///sort(arr,arr+n,greater<int>()) for decrement of array
/*every external angle sum=360 degree
  angle find using polygon hand(n) ((n-2)*180)/n*/
///Floor[Log(b)  N] + 1 = the number of digits when any number is represented in base b
using namespace std;
typedef long long ll;

int main()
{
    int tst;
    cin>>tst;
    while(tst--)
    {
        string str,rev;
        cin>>str;
        rev=str;
        reverse(rev.begin(),rev.end());
        if(rev==str)
        {
            for(int i=1; i<str.size(); i++)
                if(str[0]!=str[i])
                {
                    swap(str[0],str[i]);
                    break;
                }
            rev=str;
            reverse(rev.begin(),rev.end());
            if(rev==str) cout<<"-1"<<endl;
            else cout<<str<<endl;
        }
        else cout<<str<<endl;
    }
    return 0;
}

///Alhamdulillah 
Problem Link:https://codeforces.com/contest/1093/problem/B


Comments

Popular posts from this blog

Codeforces Beta Round #53 (A. Square Earth?)

Bismillahir Rahmanir Rahim ///Author: Tanvir Ahmmad ///CSE,Islamic University,Bangladesh #include< iostream > #include< cstdio > #include< algorithm > #include< string > #include< cstring > #include< sstream > #include< cmath > #include< cstring > #include< vector > #include< queue > #include< map > #include< set > #include< stack > #include< vector > #include< iterator > #include   < functional >   ///sort(arr,arr+n,greater<int>()) for decrement of array /*every external angle sum=360 degree   angle find using polygon hand(n) ((n-2)*180)/n*/ ///Floor[Log(b)  N] + 1 = the number of digits when any number is represented in base b using   namespace  std; typedef   long   long ...

Codeforces round 1676(A. Lucky?)

Just count the  first three  &  last three  number ///Bismillahir Rahmanir Rahim ///Author: Tanvir Ahmmad ///CSE,Islamic University,Bangladesh #include< iostream > #include< cstdio > #include< algorithm > #include< string > #include< cstring > #include< sstream > #include< cmath > #include< cstring > #include< vector > #include< queue > #include< map > #include< set > #include< stack > #include< vector > #include< iterator > #include   < functional >   ///sort(arr,arr+n,greater<int>()) for decrement of array /*every external angle sum=360 degree   angle find using polygon hand(n) ((n-2)*180)/n*/ ///Floor[Log(b)  N] + 1 = the number of digits when any number is repres...

Codeforces round 1676(C. Most Similar Words)

  Just compare every pair distace such as  best & cost b & c => distace is 1 e & o => distace is 10 s & s => distace is 0 t & t => distace is 0 so the answer will be= (1+10+0+0) =11 ///Bismillahir Rahmanir Rahim ///Author: Tanvir Ahmmad ///CSE,Islamic University,Bangladesh #include< iostream > #include< cstdio > #include< algorithm > #include< string > #include< cstring > #include< sstream > #include< cmath > #include< cstring > #include< vector > #include< queue > #include< map > #include< set > #include< stack > #include< vector > #include< iterator > #include   < functional >   ///sort(arr,arr+n,greater<int>()) for d...