#C8750. Exact String Transformation

    ID: 52767 Type: Default 1000ms 256MiB

Exact String Transformation

Exact String Transformation

You are given two strings S and T of equal length and an integer k. Your task is to determine whether you can transform string S into string T by performing exactly k operations. In one operation, you can change a single character of S to any other character. The transformation is only possible if the number of positions at which the two strings differ equals exactly k (note that if the lengths are not equal, the transformation is impossible).

Formally, let \(\Delta(S,T)\) denote the number of indices \(i\) such that \(S_i \neq T_i\). You should determine if \(\Delta(S,T)=k\).

Examples:

  • For S = "abc", T = "def", and k = 3, the answer is True because every character differs.
  • For S = "aaaa", T = "bbbb", and k = 5, the answer is False because the strings differ in 4 positions, not 5.

inputFormat

The input consists of three lines:

  1. The first line contains the source string S.
  2. The second line contains the target string T.
  3. The third line contains an integer k, the number of operations.

It is guaranteed that S and T consist only of printable characters.

outputFormat

Output a single line containing either True or False (without quotes):

  • True if it is exactly possible to transform S into T with k operations.
  • False otherwise.
## sample
abc
def
3
True