Advertisement
Guest User

A

a guest
Feb 24th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const char o[3] = {'0','o','O'};
  5. const char is[5] = {'1','I','l','i','L'};
  6.  
  7. bool same(string a, string b) {
  8.     if (a.length() != b.length() ) return false;
  9.     for (int i = 0; i<(int)a.length(); i++) {
  10.         int os=0,iss=0;
  11.         for (int j = 0; j<3; j++) {
  12.             if (a[i] == o[j])os++;
  13.             if (b[i]==o[j]) os++;
  14.         }
  15.         for (int j = 0;j<5;j++) {
  16.             if (a[i] == is[j]) iss++;
  17.             if (b[i] == is[j]) iss++;
  18.         }
  19.         if (!(toupper(a[i])==toupper(b[i]) || iss==2 || os==2))
  20.             return false;
  21.     }
  22.     return true;
  23. }
  24.  
  25. int main() {
  26.     int n;
  27.     string s,t;
  28.     cin >>s>>n;
  29.     for (int i =0; i<n;i++){
  30.         cin >> t;
  31.         if (same(s,t)) {
  32.             cout << "No";
  33.             return 0;
  34.         }
  35.     }
  36.     cout <<"Yes";
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement