CF822E.Liar

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The first semester ended. You know, after the end of the first semester the holidays begin. On holidays Noora decided to return to Vičkopolis. As a modest souvenir for Leha, she brought a sausage of length mm from Pavlopolis. Everyone knows that any sausage can be represented as a string of lowercase English letters, the length of which is equal to the length of the sausage.

Leha was very pleased with the gift and immediately ate the sausage. But then he realized that it was a quite tactless act, because the sausage was a souvenir! So the hacker immediately went to the butcher shop. Unfortunately, there was only another sausage of length nn in the shop. However Leha was not upset and bought this sausage. After coming home, he decided to cut the purchased sausage into several pieces and number the pieces starting from 11 from left to right. Then he wants to select several pieces and glue them together so that the obtained sausage is equal to the sausage that Noora gave. But the hacker can glue two pieces together only when the number of the left piece is less than the number of the right piece. Besides he knows that if he glues more than xx pieces, Noora will notice that he has falsified souvenir sausage and will be very upset. Of course Leha doesn’t want to upset the girl. The hacker asks you to find out whether he is able to cut the sausage he bought, and then glue some of the pieces so that Noora doesn't notice anything.

Formally, you are given two strings ss and tt . The length of the string ss is nn , the length of the string tt is mm . It is required to select several pairwise non-intersecting substrings from ss , so that their concatenation in the same order as these substrings appear in ss , is equal to the string tt . Denote by f(s,t)f(s,t) the minimal number of substrings to be chosen so that their concatenation is equal to the string tt . If it is impossible to choose such substrings, then f(s,t)=f(s,t)=∞ . Leha really wants to know whether it’s true that f(s,t)<=xf(s,t)<=x .

输入格式

The first line contains single integer nn ( 1<=n<=1051<=n<=10^{5} ) — length of sausage bought by Leha, i.e. the length of the string ss .

The second line contains string ss of the length nn consisting of lowercase English letters.

The third line contains single integer mm ( 1<=m<=n1<=m<=n ) — length of sausage bought by Noora, i.e. the length of the string tt .

The fourth line contains string tt of the length mm consisting of lowercase English letters.

The fifth line contains single integer xx ( 1<=x<=301<=x<=30 ) — the maximum number of pieces of sausage that Leha can glue so that Noora doesn’t notice anything.

输出格式

In the only line print "YES" (without quotes), if Leha is able to succeed in creating new sausage so that Noora doesn't notice anything. Otherwise print "NO" (without quotes).

输入输出样例

  • 输入#1

    9
    hloyaygrt
    6
    loyyrt
    3
    

    输出#1

    YES
    
  • 输入#2

    9
    hloyaygrt
    6
    loyyrt
    2
    

    输出#2

    NO
    

说明/提示

Let's consider the first sample.

In the optimal answer, Leha should cut the sausage he bought in the following way: hloyaygrt = h + loy + a + y + g + rt. Then he numbers received parts from 11 to 66 :

  • h — number 11
  • loy — number 22
  • a — number 33
  • y — number 44
  • g — number 55
  • rt — number 66

Hereupon the hacker should glue the parts with numbers 22 , 44 and 66 and get sausage loyygrt equal to one that is given by Noora. Thus, he will have to glue three pieces. Since x=3x=3 you should print "YES" (without quotes).

In the second sample both sausages coincide with sausages from the first sample. However since x=2x=2 you should print "NO" (without quotes).

首页