Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
229939 | 2224梁翁思译 | *小美的字符串匹配度 | C++ | 通过 | 100 | 0 MS | 292 KB | 655 | 2024-01-07 14:08:21 |
#include <bits/stdc++.h> using namespace std; int n; string a; string b; bool c[1005] = {0}; int sum = 0; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; cin >> a >> b; for(int i = 0;i < n;i++) { if(a[i] == b[i]) { c[i] = 1; sum++; } } int mx = 0; int mxx = -0x7f7f7f7f; for(int i = 0;i < n - 1;i++) { for(int j = i+1;j < n;j++) { mx = 0; if(b[i] == a[j] && !c[j]) { mx++; } if(b[j] == a[i] && !c[i]) { mx++; } mxx = max(mx,mxx); if(mxx == 2) { break; } } } cout << sum + mxx << endl; return 0; }