102170: [AtCoder]ABC217 A - Lexicographic Order

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $100$ points

Problem Statement

You are given two different strings $S$ and $T$.
If $S$ is lexicographically smaller than $T$, 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 $S$ and $T$.

Below, let $S_i$ denote the $i$-th character of $S$. Also, if $S$ is lexicographically smaller than $T$, we will denote that fact as $S \lt T$; if $S$ is lexicographically larger than $T$, we will denote that fact as $S \gt T$.

  1. Let $L$ be the smaller of the lengths of $S$ and $T$. For each $i=1,2,\dots,L$, we check whether $S_i$ and $T_i$ are the same.
  2. If there is an $i$ such that $S_i \neq T_i$, let $j$ be the smallest such $i$. Then, we compare $S_j$ and $T_j$. If $S_j$ comes earlier than $T_j$ in alphabetical order, we determine that $S \lt T$ and quit; if $S_j$ comes later than $T_j$, we determine that $S \gt T$ and quit.
  3. If there is no $i$ such that $S_i \neq T_i$, we compare the lengths of $S$ and $T$. If $S$ is shorter than $T$, we determine that $S \lt T$ and quit; if $S$ is longer than $T$, we determine that $S \gt T$ and quit.

Note that many major programming languages implement lexicographical comparison of strings as operators or functions in standard libraries. For more detail, see your language's reference.

Constraints

  • $S$ and $T$ are different strings, each of which consists of lowercase English letters and has a length of between $1$ and $10$ (inclusive).

Input

Input is given from Standard Input in the following format:

$S$ $T$

Output

If $S$ is lexicographically smaller than $T$, print Yes; otherwise, print No.


Sample Input 1

abc atcoder

Sample Output 1

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.


Sample Input 2

arc agc

Sample Output 2

No

Sample Input 3

a aa

Sample Output 3

Yes

Input

题意翻译

给出两个不同的完全由英文小写字母组成的字符串 $s,t$ ,问 $s$ 的字典序是否小于 $t$ 。

Output

分数:100分

问题描述

给你两个不同的字符串$S$和$T$。

什么是字典序?

简单来说,字典序就是字典中单词的排列顺序。更正式的定义是,确定不同字符串$S$和$T$之间字典序的方法如下。

以下,我们用$S_i$表示字符串$S$的第$i$个字符。如果$S$在字典序上小于$T$,我们用$S \lt T$表示;如果$S$在字典序上大于$T$,我们用$S \gt T$表示。

  1. 让$L$为字符串$S$和$T$中长度较小的一个。对于每个$i=1,2,\dots,L$,我们检查$S_i$和$T_i$是否相同。
  2. 如果存在一个$i$,使得$S_i \neq T_i$,那么让$j$为这样的$i$中的最小值。然后,我们比较$S_j$和$T_j$。如果$S_j$在字母顺序上比$T_j$靠前,我们确定$S \lt T$并退出;如果$S_j$在字母顺序上比$T_j$靠后,我们确定$S \gt T$并退出。
  3. 如果不存在一个$i$,使得$S_i \neq T_i$,我们比较字符串$S$和$T$的长度。如果$S$比$T$短,我们确定$S \lt T$并退出;如果$S$比$T$长,我们确定$S \gt T$并退出。

注意,许多主要的编程语言在标准库中实现了字符串的字典序比较。更多细节,请参阅你的编程语言的参考文档。

约束条件

  • $S$和$T$是不同的字符串,每个都由小写英文字母组成,长度在$1$到$10$之间(包括$1$和$10$)。

输入

输入从标准输入给出,格式如下:

$S$ $T$

输出

如果$S$在字典序上小于$T$,输出Yes;否则,输出No


样例输入1

abc atcoder

样例输出1

Yes

abcatcoder以相同的字符开始,但它们的第二个字符不同。由于字母顺序中bt之前,我们可以看出abc在字典序上小于atcoder


样例输入2

arc agc

样例输出2

No

样例输入3

a aa

样例输出3

Yes

加入题单

算法标签: