Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #include <algorithm>
- #define lli long long int
- #define li long int
- #define mod 1000000007
- #define ld long double
- #define pb push_back
- using namespace std;
- int main(){
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int n;
- cin>>n;
- string s;
- cin>>s;
- string k=s;
- reverse(k.begin(),k.end());
- set<char> stt;
- for (int i = 0; i < s.size(); i++)
- {
- stt.insert(s[i]);
- }
- int h=(s.size())/(stt.size());
- if(k==s || h%2==0){
- cout<<0<<endl;
- return 0;
- }
- lli p=stt.size();
- map<char,int> m;
- lli ct=0;
- for (lli i = 0; i < s.size(); i++)
- {
- m[s[i]]=m[s[i]]+1;
- }
- for (auto it=m.begin();it!=m.end();it++)
- {
- if( (*it).second % 2==0 ){
- continue;
- }
- if( (*it).second % 2!=0){
- ct++;
- }
- }
- // if(p%2!=0){
- // cout<<ct-1<<endl;
- // }
- // else{
- cout<<ct-1<<endl;
- // }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment