fork download
  1. #pragma comment(linker, "/stack:200000000")
  2. #pragma GCC optimize("Ofast")
  3. #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
  4. #include<bits/stdc++.h>
  5.  
  6. using namespace std;
  7.  
  8. #define FTB(i,a,b) for(LL i=a;i<=b;i++)
  9. #define FT(i,a,b) for(LL i=a;i<b;i++)
  10. #define FGB(i,a,b) for(LL i=a;i>=b;i--)
  11. #define FG(i,a,b) for(LL i=a;i>b;i--)
  12. #define endl "\n"
  13. #define PB push_back
  14. #define mp make_pair
  15. #define fi first
  16. #define se second
  17. #define PI 3.1415926535897
  18. #define lbnd(dau,cuoi,giatri) lower_bound(dau,cuoi,giatri)
  19. #define ubnd(dau,cuoi,giatri) upper_bound(dau,cuoi,giatri)
  20. typedef double DB;
  21. typedef long long LL;
  22. typedef unsigned long long UL;
  23. typedef long double LD;
  24. typedef pair<LL,LL> II;
  25. typedef vector<LL> VI;
  26. typedef vector<bool> VB;
  27.  
  28.  
  29. LL n,res=0,tmp;
  30. string a,b;
  31.  
  32. string s;
  33.  
  34.  
  35. int main(){
  36. ios::sync_with_stdio(false);cin.tie(0);
  37. cin>>n;
  38. cin>>a;
  39. cin>>b;
  40. a="1"+a;
  41. b="1"+b;
  42. FTB(i,1,n/2){
  43. s="";
  44. s+=a[i];
  45. s+=b[i];
  46. s+=a[n+1-i];
  47. s+=b[n+1-i];
  48. sort(s.begin(),s.end());
  49. tmp=1;
  50. FT(i,1,4){
  51. if(s[i]!=s[i-1]) tmp++;
  52. }
  53. if(tmp==4){
  54. res+=2;
  55. }
  56. else if(tmp==2){
  57. if(s[1]==s[2]){
  58. res++;
  59. }
  60. }
  61. else if(tmp==3){
  62. if(a[i]==a[n-i+1]) res+=2;
  63. else if(b[i]==b[n-i+1]) res+=2;
  64. else res++;
  65. }
  66. }
  67. if(n%2==1){
  68. n++;
  69. if(a[n/2]!=b[n/2]) res++;
  70. }
  71. cout<<res;
  72.  
  73.  
  74.  
  75. return 0;
  76. }
Success #stdin #stdout 0s 4200KB
stdin
Standard input is empty
stdout
Standard output is empty