提交时间:2024-01-07 14:54:54
运行 ID: 230010
#include <bits/stdc++.h> using namespace std; long long n; string s,t; int ans; bool b=false,c=false; int main() { scanf("%lld",&n); cin>>s>>t; for(int i=0; i<n; i++) { if(s[i]==t[i]) { ans++; } else { int pos; pos=s.rfind(t[i]); if(pos!=string::npos) { b=true; if(c==false) { if(t[pos]!=s[pos]||t[pos]==s[i]) { ans+=2; c=true; } } } } } if(b==true&&c==false) printf("%d\n",ans+1); else printf("%d\n",ans); return 0; }