Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 1000 + 5;
- char strA[N], strB[N];
- bool dp[N][N];
- int main(){
- int Q;
- scanf("%d", &Q);
- while(Q--){
- scanf(" %s %s", strA + 1, strB + 1);
- int lenA = strlen(strA + 1);
- int lenB = strlen(strB + 1);
- dp[0][0] = true;
- for(int i = 1; i <= lenA; ++i){
- for(int j = 0; j <= lenB; ++j){
- bool ans = false;
- if('a' <= strA[i] && strA[i] <= 'z'){
- ans |= dp[i - 1][j];
- }
- if(strA[i] == strB[j] || toupper(strA[i]) == strB[j]){
- ans |= dp[i - 1][j - 1];
- }
- dp[i][j] = ans;
- }
- }
- if(dp[lenA][lenB]){
- cout << "YES\n";
- } else {
- cout << "NO\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement