fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int y;cin>>y;while(y--){
  6. int x,n=0;
  7. string l,a,b,f;cin>>x;cin>>l;f==l;
  8. reverse(f.begin(),f.end());if(l==f) cout<<0<<"\n";else{
  9. if(x%2!=0){
  10. x=x/2;a=l.substr(0,x);b=l.substr(x+1,x);}
  11. else{
  12. x=x/2;a=l.substr(0,x);b=l.substr(x,x);
  13. }
  14. reverse(b.begin(),b.end());
  15. for(int i=0;i<x;i++){
  16. if(a[i]!=b[i]) n++;
  17. }
  18. n=(n+1)/2;
  19. cout<<n<<"\n";}
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5432KB
stdin
2
5
11011
6
011101
stdout
0
1