#C3507. Can Obtain by k Operations
Can Obtain by k Operations
Can Obtain by k Operations
Given two strings s1 and s2 of equal length and an integer k, determine if s2 can be obtained from s1 by performing exactly k operations. In one operation, you can change a single character of s1 into any other character. Formally, let \(D = \sum_{i=1}^{n} 1\{s1_i \neq s2_i\}\) be the number of positions at which the two strings differ. The answer is "YES" if and only if \(D = k\), otherwise, the answer is "NO".
inputFormat
The input consists of three lines:
- The first line contains an integer k, the exact number of operations.
- The second line contains the string s1.
- The third line contains the string s2.
It is guaranteed that s1 and s2 have the same length.
outputFormat
Output a single line containing "YES" if s2 can be obtained from s1 by performing exactly k operations, and "NO" otherwise.
## sample3
abcdef
abcxyz
YES