#K37302. Taco Transformation

    ID: 25946 Type: Default 1000ms 256MiB

Taco Transformation

Taco Transformation

Given two strings s and t, determine whether s can be transformed into t by duplicating and inserting characters that already exist in s. No new characters can be introduced during the transformation. In other words, for every character \( c \) in s, the frequency of \( c \) in t must be at least as high as in s, and t must not contain any character that does not appear in s.

Formal Description:

Let \( f(x, c) \) denote the frequency of character \( c \) in string \( x \). The transformation is possible if and only if for every character \( c \) in s, we have \[ f(t, c) \ge f(s, c)\] and for every character \( c \) in t, \( c \) must appear in s.

Examples:

  • For s = "abc" and t = "aabbcc", the output is True.
  • For s = "abc" and t = "abcd", the output is False because a new character 'd' is introduced.
  • For s = "xyz" and t = "xyz", the output is True.

inputFormat

The input consists of two lines. The first line contains the string s, and the second line contains the string t.

outputFormat

Output a single line containing either "True" if s can be transformed into t according to the rules, or "False" otherwise.## sample

abc
aabbcc
True