100 atcoder#ABC082B. [ABC082B] Two Anagrams
[ABC082B] Two Anagrams
Score : points
Problem Statement
You are given strings and , consisting of lowercase English letters. You will create a string by freely rearranging the characters in . You will also create a string by freely rearranging the characters in . Determine whether it is possible to satisfy for the lexicographic order.
Notes
For a string of length and a string of length , we say for the lexicographic order if either one of the following two conditions holds true:
- and , , ..., .
- There exists () such that , , ..., and . Here, letters are compared using alphabetical order.
For example, xy
xya
and atcoder
atlas
.
Constraints
- The lengths of and are between and (inclusive).
- and consists of lowercase English letters.
Input
Input is given from Standard Input in the following format:
Output
If it is possible to satisfy , print Yes
; if it is not, print No
.
yx
axy
Yes
We can, for example, rearrange yx
into xy
and axy
into yxa
. Then, xy
yxa
.
ratcode
atlas
Yes
We can, for example, rearrange ratcode
into acdeort
and atlas
into tslaa
. Then, acdeort
tslaa
.
cd
abc
No
No matter how we rearrange cd
and abc
, we cannot achieve our objective.
w
ww
Yes
zzz
zzz
No