QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 1024 MB Puntuación total: 100

#23993. Find The String

Estadísticas

Problem Statement

You are given a string $S$ of length $N$, a string $T$ of length $M$, and a positive integer $K$. Each character of $S$ and $T$ is a lowercase English letter.

Let $X$ be the string obtained by repeating $S$ for $K$ times. Print Yes if $T$ is contained in $X$ as a substring, and No otherwise. Here, a substring of $X$ refers to a string obtained by deleting $0$ or more characters from the beginning of $X$ and $0$ or more characters from the end of $X$.

Constraints

  • $1 \le N \le 100$.
  • $S$ is a string of length $N$ consisting only of lowercase English letters.
  • $1 \le M \le 100$.
  • $T$ is a string of length $M$ consisting only of lowercase English letters.
  • $1 \le K \le 10^9$.
  • $N, M, K$ are integers.

Subtasks

  1. ($25$ points) $K = 1$.
  2. ($25$ points) $K \le 100$.
  3. ($25$ points) Each character of $S, T$ is a.
  4. ($25$ points) No additional constraints.

Input

The input is given in the following format:

N
S
M
T
K

Output

Print Yes if $T$ is contained in $X$ as a substring, and No otherwise.

Do not print anything other than the answer. (For example, do not print any text prompting for input.)

For the answer format, you may refer to the practice problems and their sample solutions.

Sample 1

Input

4
joig
3
joi
1

Output

Yes

$X$ is joig, which contains joi as a substring. Therefore, print Yes.

This sample input satisfies the constraints of Subtasks $1, 2, 4$.

Sample 2

Input

3
joi
4
joig
2

Output

No

$X$ is joijoi, which does not contain joig as a substring. Therefore, print No.

This sample input satisfies the constraints of Subtasks $2, 4$.

Sample 3

Input

4
aaaa
1
a
1000000000

Output

Yes

$X$ is a string consisting of $4 \times 10^9$ occurrences of a, which contains a as a substring. Therefore, print Yes.

This sample input satisfies the constraints of Subtasks $3, 4$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.