Advertisement
fahad005

Untitled

Dec 23rd, 2021
984
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.59 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. //
  4. #define ll long long
  5. #define ull unsigned long long
  6. #define mx 100010
  7. #define mod 1000000007
  8. #define inf INT_MAX
  9. #define pi acos(-1.0)
  10. #define endl '\n'
  11. #define pb push_back
  12. #define pll pair<ll, ll>
  13. #define vll vector<ll>
  14. #define vpll vector<pll>
  15. #define Fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
  16. //
  17. int main() {
  18.     ll t;
  19.     cin >> t;
  20.  
  21.     while (t--) {
  22.         ll n;
  23.         cin >> n;
  24.  
  25.         string s, p;
  26.         cin >> s >> p;
  27.  
  28.         vll charCount(200, 0);
  29.  
  30.         for (ll i = 0; i < s.length(); i++) {
  31.             if (s[i] == '?' || p[i] == '?') {
  32.                 if (s[i] == p[i]) continue;
  33.                 ll x = p[i] - '0', y = s[i] - '0';
  34.                 //cout << x << " " << y << endl; //! test
  35.                 if (s[i] == '?') charCount[x]++;
  36.                 else charCount[y]++;
  37.             }
  38.         }
  39.  
  40.         ll charIdxV = 0, charIdxC = 0, tempV = 0, tempC = 0;
  41.         for (ll i = 49; i <= 74; i++) {
  42.             //cout << charCount[i] << " "; //! test
  43.             if (tempV < charCount[i] && (i == 49 || i == 53 || i == 57 || i == 63 || i == 69)) {
  44.                 tempV = charCount[i];
  45.                 charIdxV = i;
  46.             }
  47.             else if (tempC < charCount[i] && (i != 49 && i != 53 && i != 57 && i != 63 && i != 69)) {
  48.                 tempC = charCount[i];
  49.                 charIdxC = i;
  50.             }
  51.  
  52.         }
  53.  
  54.         ll countV = 0, countC = 0, countN = 0;
  55.         bool cons = true, vow = true;
  56.         string p1 = p, s1 = s;
  57.         if (charIdxC != 0) charIdxC += 48;
  58.         else charIdxC = 98;
  59.         if (charIdxV != 0) charIdxV += 48;
  60.         else charIdxV = 97;
  61.         //cout << charIdxV << " " << charIdxC << endl; //! test
  62.         for (ll i = 0; i < s.length(); i++) {
  63.  
  64.             if (s[i] == '?') s[i] = (char)charIdxV;
  65.             if (p[i] == '?') p[i] = (char)charIdxV;
  66.             //cout << s[i] << " " << p[i] << endl; //! test
  67.             if (s[i] != p[i]) countV++;
  68.             if ((s[i] != p[i]) && (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u') && (p[i] == 'a' || p[i] == 'e' || p[i] == 'i' || p[i] == 'o' || p[i] == 'u')) {
  69.                 countV++;
  70.                 //cout << "here" << endl; //! test
  71.             }
  72.             else if ((s[i] != p[i]) && (s[i] != 'a' && s[i] != 'e' && s[i] != 'i' && s[i] != 'o' && s[i] != 'u') && (p[i] != 'a' && p[i] != 'e' && p[i] != 'i' && p[i] != 'o' && p[i] != 'u')) countV++;
  73.  
  74.             if (s1[i] == '?') s1[i] = (char)charIdxC;
  75.             if (p1[i] == '?') p1[i] = (char)charIdxC;
  76.             if (s1[i] != p1[i]) countC++;
  77.             if ((s1[i] != p1[i]) && (s1[i] != 'a' && s1[i] != 'e' && s1[i] != 'i' && s1[i] != 'o' && s1[i] != 'u') && (p1[i] != 'a' && p1[i] != 'e' && p1[i] != 'i' && p1[i] != 'o' && p1[i] != 'u')) countC++;
  78.             else if ((s1[i] != p1[i]) && (s1[i] == 'a' || s1[i] == 'e' || s1[i] == 'i' || s1[i] == 'o' || s1[i] == 'u') && (p1[i] == 'a' || p1[i] == 'e' || p1[i] == 'i' || p1[i] == 'o' || p1[i] == 'u')) {
  79.                 countC++;
  80.                 //cout << "here" << endl; //! test
  81.             }
  82.         }
  83.  
  84.         //cout << countV << " " << countC << endl; //! test
  85.  
  86.         // if (charIdxV == 0 && cons == false) cout << countV << endl;
  87.         // else if (charIdxC == 0 && vow == false) cout << countC << endl;
  88.         // else if (!cons) cout << countV << endl;
  89.         // else if (!vow) cout << countC << endl;
  90.         // else cout << 0 << endl;
  91.         //cout << "   " << countN << endl;
  92.         cout << min(countV, countC) << endl;
  93.     }
  94.  
  95. }
  96.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement