Advertisement
mickypinata

TAChi-T004: Elision

Dec 4th, 2021
990
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int N = 1000 + 5;
  5.  
  6. char strA[N], strB[N];
  7. bool dp[N][N];
  8.  
  9. int main(){
  10.  
  11.     int Q;
  12.     scanf("%d", &Q);
  13.     while(Q--){
  14.         scanf(" %s %s", strA + 1, strB + 1);
  15.         int lenA = strlen(strA + 1);
  16.         int lenB = strlen(strB + 1);
  17.         dp[0][0] = true;
  18.         for(int i = 1; i <= lenA; ++i){
  19.             for(int j = 0; j <= lenB; ++j){
  20.                 bool ans = false;
  21.                 if('a' <= strA[i] && strA[i] <= 'z'){
  22.                     ans |= dp[i - 1][j];
  23.                 }
  24.                 if(strA[i] == strB[j] || toupper(strA[i]) == strB[j]){
  25.                     ans |= dp[i - 1][j - 1];
  26.                 }
  27.                 dp[i][j] = ans;
  28.             }
  29.         }
  30.         if(dp[lenA][lenB]){
  31.             cout << "YES\n";
  32.         } else {
  33.             cout << "NO\n";
  34.         }
  35.     }
  36.  
  37.     return 0;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement