#C11789. Magic Runes: Subsequence Verification
Magic Runes: Subsequence Verification
Magic Runes: Subsequence Verification
You are given two strings: a magical script string s
and a runes string r
. Your task is to determine whether the runes string r
can be obtained from the script string s
by deleting some characters (possibly none) without changing the order of the remaining characters.
In other words, check if r
is a subsequence of s
.
Note: The matching must respect the order of characters as they appear in s
.
The problem can be formally stated using the formula:
\(\text{Find if } r = s_{i_1}s_{i_2}\ldots s_{i_k} \text{ with } 1 \leq i_1 < i_2 < \cdots < i_k \leq |s|\).
inputFormat
The input consists of two lines. The first line contains the magical script string s
. The second line contains the runes string r
.
outputFormat
Output a single line containing either Possible
if r
is a subsequence of s
, or Impossible
otherwise.
abcde
ace
Possible