100 atcoder#ABC217A. [ABC217A] Lexicographic Order
[ABC217A] Lexicographic Order
Score : points
Problem Statement
You are given two different strings and .
If is lexicographically smaller than , print Yes
; otherwise, print No
.
What is the lexicographical order?
Simply speaking, the lexicographical order is the order in which words are listed in a dictionary. As a more formal definition, here is the algorithm to determine the lexicographical order between different strings and .
Below, let denote the -th character of . Also, if is lexicographically smaller than , we will denote that fact as ; if is lexicographically larger than , we will denote that fact as .
- Let be the smaller of the lengths of and . For each , we check whether and are the same.
- If there is an such that , let be the smallest such . Then, we compare and . If comes earlier than in alphabetical order, we determine that and quit; if comes later than , we determine that and quit.
- If there is no such that , we compare the lengths of and . If is shorter than , we determine that and quit; if is longer than , we determine that and quit.
Constraints
- and are different strings, each of which consists of lowercase English letters and has a length of between and (inclusive).
Input
Input is given from Standard Input in the following format:
Output
If is lexicographically smaller than , print Yes
; otherwise, print No
.
abc atcoder
Yes
abc
and atcoder
begin with the same character, but their second characters are different. Since b
comes earlier than t
in alphabetical order, we can see that abc
is lexicographically smaller than atcoder
.
arc agc
No
a aa
Yes