atcoder#ABC198D. [ABC198D] Send More Money
[ABC198D] Send More Money
Score : points
Problem Statement
Given strings consisting of lowercase English letters, solve the alphametic .
Formally, determine whether there is a triple of positive integers satisfying all of the three conditions below, and find one such triple if it exists. Here, are strings representing (without leading zeros) in base ten, respectively.
- and have the same number of characters.
- .
- The -th character of and the -th character of is the same if and only if the -th character of and the -th character of are the same.
Constraints
- Each of , , is a string of length between and (inclusive) consisting of lowercase English letters.
Input
Input is given from Standard Input in the following format:
Output
If there is a triple of positive integers satisfying the conditions, print one such triple, using newline as a separator.
Otherwise, print UNSOLVABLE
instead.
a
b
c
1
2
3
Outputs such as will also be accepted, but will not since it violates the third condition (both a
and b
correspond to 1
).
x
x
y
1
1
2
Outputs such as will also be accepted, but will not since it violates the third condition (both and correspond to x
).
p
q
p
UNSOLVABLE
abcd
efgh
ijkl
UNSOLVABLE
send
more
money
9567
1085
10652