#K1796. Substring Existence in Sorted Substrings

    ID: 24594 Type: Default 1000ms 256MiB

Substring Existence in Sorted Substrings

Substring Existence in Sorted Substrings

You are given a string s and a substring sub. Your task is to determine whether sub appears as a contiguous substring in s when considering all possible substrings of s sorted in lexicographical order. Formally, you need to check if sub is one of the substrings obtained from s by taking any contiguous segment of characters. If it exists, print YES, otherwise print NO.

Note: The order in which the substrings are sorted does not affect the presence check. Essentially, you are checking if sub is a contiguous substring of s.

For example, given s = "abc", the sorted substrings are ["a", "ab", "abc", "b", "bc", "c"]. Since "ab" appears in this list, the output should be YES.

inputFormat

The input consists of exactly two lines:

  1. The first line contains the string s.
  2. The second line contains the substring sub.

Both strings consist of lowercase English letters only.

outputFormat

Output a single line containing YES if sub is a contiguous substring of s, and NO otherwise.

## sample
abc
ab
YES