跳到正文

题解

题解:P14747 相似字符串

yiziheng约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年12月14日
收录
2026年3月8日
更新
2026年11月14日
篇幅
约 1 分钟
题目
P14747

版本

  1. v1当前

a water problem.

思路

统计两个字符串中不同的字符个数和相似情况的出现次数,若二者相等,则两个字符串是相似的。

特别的,如果二者皆为 00 无需特判,因为这样也视为两个字符串相似,且程序会输出正确结果。

AC CODE

C++
#include<bits/stdc++.h>
using namespace std;
string s,t;
int s1,t1;
main(){
    cin>>s>>t;
    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i])s1++;
        if(s[i]=='I' and t[i]=='l')t1++;
        if(s[i]=='l' and t[i]=='I')t1++;
    }
    if(s1==t1)cout<<"YES";
    else cout<<"NO";
}
原文