Accepted
Code
#include <bits/stdc++.h>
using namespace std;
bool validSub(string s1, string s2, int m, int n)
{
if (m == 0)
return true;
if (n == 0)
return false;
if (s1[m - 1] == s2[n - 1])
return validSub(s1, s2, m - 1, n - 1);
return validSub(s1, s2, m, n - 1);
}
int main()
{
int t;
cin >> t;
while (t--)
{
string s1, s2;
cin >> s2 >> s1;
int m = s1.size();
int n = s2.size();
if (validSub(s1, s2, m, n))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1020 Favourite footballer
- Contest
- Brain booster - 1
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2023-12-31 14:54:54
- Judged At
- 2024-11-11 03:46:06
- Judged By
- Score
- 100
- Total Time
- 91ms
- Peak Memory
- 98.43 MiB