题目链接:https://abc082.contest.atcoder.jp/tasks/abc082_b

Time limit : 2sec / Memory limit : 256MB

Score : 200 points

Problem Statement

You are given strings s and t, consisting of lowercase English letters. You will create a string s' by freely rearranging the characters in s. You will also create a string t' by freely rearranging the characters in t. Determine whether it is possible to satisfy s'<t' for the lexicographic order.

Notes

For a string a=a1a2…aN of length N and a string b=b1b2…bM of length M, we say a<b for the lexicographic order if either one of the following two conditions holds true:

  • N<M and a1=b1a2=b2, ..., aN=bN.
  • There exists i (1≤iN,M) such that a1=b1a2=b2, ..., ai−1=bi−1 and ai<bi. Here, letters are compared using alphabetical order.

For example, xy < xya and atcoder < atlas.

Constraints

  • The lengths of s and t are between 1 and 100 (inclusive).
  • s and t consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

s
t

Output

If it is possible to satisfy s'<t', print Yes; if it is not, print No.


Sample Input 1

Copy
yx
axy

Sample Output 1

Copy
Yes

We can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.


Sample Input 2

Copy
ratcode
atlas

Sample Output 2

Copy
Yes

We can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.


Sample Input 3

Copy
cd
abc

Sample Output 3

Copy
No

No matter how we rearrange cd and abc, we cannot achieve our objective.


Sample Input 4

Copy
w
ww

Sample Output 4

Copy
Yes

Sample Input 5

Copy
zzz
zzz

Sample Output 5

Copy
No

补漏洞
 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
using namespace std;
char a[];
char b[];
int main()
{
while(scanf("%s%s",&a,&b)!=EOF){
int la=strlen(a);
int lb=strlen(b);
sort(a,a+la);
sort(b,b+lb);
if(a[]<b[lb-]) cout<<"Yes"<<endl;
else if(a[]>b[lb-]) cout<<"No"<<endl;
else{
if(a[]==a[la-]&&b[]==b[lb-]&&a[]==b[]){
if(lb>la) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
continue;
}
int k=;
for(int i=;i<la;i++){
for(int j=;j<lb;j++){
if(b[j]>a[i]){
k++;
break;
}
}
}
if(k==la) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
}
return ;
}

AtCoder Beginner Contest 082 B - Two Anagrams的更多相关文章

  1. AtCoder Beginner Contest 082 A - Round Up the Mean

    题目链接:https://abc082.contest.atcoder.jp/tasks/abc082_a Time limit : 2sec / Memory limit : 256MB Score ...

  2. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  3. AtCoder Beginner Contest 052

    没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...

  4. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  5. AtCoder Beginner Contest 136

    AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...

  6. AtCoder Beginner Contest 137 F

    AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...

  7. AtCoder Beginner Contest 076

    A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...

  8. AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】

    AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...

  9. AtCoder Beginner Contest 064 D - Insertion

    AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...

随机推荐

  1. Git/GitHub基本操作

    GitGit是分布式版本控制工具,SVN是集中式版本控制,有单点故障的问题GitHub是Git的代码托管中心,类似的国内有码云,是远程维护库Git的优势大部分操作在本地完成,不需要联网完整性有保证尽可 ...

  2. SSIS--(1)

    目标:两组数据比对,A 来源Excel ,B 来源 Sql server DB ,比对合并,取值放入目标 C 中 首先使用工具SSIS包 一,以数据源 A 为准核对B 中是否有A 的数据和计算等动作 ...

  3. 002-linux命令-文件和目录、查看文件内容-文件和目录、查看文件内容

    一.文件和目录 cd /home :进入‘/home’目录 cd .. 返回上一级目录 cd ../..返回上两级目录 cd 进入个人的主目录 cd ~user1进入个人的主目录 cd - 返回上次所 ...

  4. "当前不会命中断点,没有与此行关联的可执行代码"可能和"断点位置不准确"有关

    今天用VS调试代码遇到一件怪事,在函数结束前的return那一行打了断点,却报"当前不会命中断点,没有与此行关联的可执行代码".看了自己是debug模式,而且没有开启优化,不应该出 ...

  5. Pycharm增加新安装Python的路径

    Pycharm默认的Python是python2,但是如果代码是python3写的,就需要在pycharm里的project interpreter增加python3 注意,一定要找到Project ...

  6. Python重要网址

    极客学院视频:http://www.jikexueyuan.com/path/python/ 知乎爬虫:https://www.zhihu.com/collection/129856874?page= ...

  7. 【Java】-NO.16.EBook.4.Java.1.005-【疯狂Java讲义第3版 李刚】- 枚举

    1.0.0 Summary Tittle:[Java]-NO.16.EBook.4.Java.1.005-[疯狂Java讲义第3版 李刚]- 枚举 Style:EBook Series:Java Si ...

  8. [LeetCode] 849. Maximize Distance to Closest Person_Easy tag: BFS

    In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is emp ...

  9. js模拟散列

    //散列 //类似于 对象存储,key-value // 存入前,先将key进行hash编码,然后存入 function HashTable(){ var hashData = []; this.dj ...

  10. sqli-labs(十二)(and和or的过滤)

    第二十五关: 这关是过滤了and 和or 输入?id=1' or '1'='1 发现or被过滤了,将or换成and也一样. 输入?id=1' oorr '1'='1 这样就可以了,将一个or置空后,o ...