#C3331. Wildcard Pattern Matching

    ID: 46747 Type: Default 1000ms 256MiB

Wildcard Pattern Matching

Wildcard Pattern Matching

Given an input string \(s\) and a pattern \(p\), determine if the pattern matches the entire string using wildcard matching. In the pattern, the character '?' matches exactly one character, while the character '*' matches any sequence of characters (including the empty sequence).

Implement a solution using dynamic programming. Your program should output YES if the pattern \(p\) matches the string \(s\) completely, and NO otherwise.

inputFormat

The input consists of two lines:

  • The first line contains the string \(s\), which consists of lowercase English letters.
  • The second line contains the pattern \(p\), which consists of lowercase English letters, '?' and '*'.

outputFormat

Output a single line containing either YES or NO indicating whether the pattern matches the entire string.

## sample
ababab
a?ab*
YES