Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
230010 陆沛埦 *小美的字符串匹配度 C++ 通过 100 0 MS 272 KB 536 2024-01-07 14:54:54

Tests(5/5):


#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; }


测评信息: