fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main() {
  6. char a[100001], b[100001];
  7. int l1, l2, l, k = 0;
  8. cin >> a >> b >> l;
  9. l1 = strlen(a);
  10. l2 = strlen(b);
  11. if (l1 < l || l2 < l) cout << "NO";
  12. else {
  13. for (int i = 0; i < l1; i ++) {
  14. for (int j = i; j <= l ; j ++) {
  15. if (a[j] == b[j]) k ++;
  16. else i++;
  17. if (k == l) {
  18. cout << "YES";
  19. return 0;
  20. }
  21. }
  22. k = 0;
  23. }
  24. cout << "NO";
  25. }
  26. return 0;
  27. }
Success #stdin #stdout 0s 15432KB
stdin
raabca
taaaca
2
stdout
YES