题目链接: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. MySQL8.0.11 组复制配置

     my.cnf [mysql] prompt='node2 [\h] {\u} (\d) > ' # [client] user = sa password = cc.123 port = 22 ...

  2. Mysql事务原理介绍

    事务 一个事务会涉及到大量的cpu计算和IO操作,这些操作被打包成一个执行单元,要么同时都完成,要么同时都不完成. 事务是一组原子性的sql命令或者说是一个独立的工作单元,如果数据库引擎能够成功的对数 ...

  3. Building an (awesome) API with NancyFX 2.0 + Dapper

    http://blog.nandotech.com/post/2016-10-25-nancyfx-webapi-dapper/?utm_source=tuicool&utm_medium=r ...

  4. poi 生成excel,最简单代码

    import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFSheet; i ...

  5. Centos7上安装及配置Apache

    Apache HTTP服务器是世界上最流行的Web服务器. 它是一款免费的开源和跨平台的HTTP服务器,提供强大的功能,可以通过各种模块进行扩展. 以下说明介绍如何在CentOS 7机器上安装和管理A ...

  6. 实验一Java开发环境的熟悉-3

    实现学生成绩管理功能(增删改,排序,查找),并进行测试(正常情况,异常情况,边界情况). 代码:

  7. python tkinter Treeview 事件绑定

    def trefun(event): sels= event.widget.selection()#event.widget获取Treeview对象,调用selection获取选择对象名称 for i ...

  8. JavaScript setInterval(定时/延时调用函数)

    setInterval是一个实现定时调用的函数,可按照指定的周期(以毫秒计)来调用函数或计算表达式.setInterval方法会不停地调用函数,直到 clearInterval被调用或窗口被关闭. 由 ...

  9. Selenium基础知识(三)元素判断

    一.由于有些页面加载完后,某些元素还没有加载,这样就会导致异常,脚本稳定性变差 为了解决这个问题,selenium提供了WebDriverWait以及implicitly_wait()等待 WebDr ...

  10. OBV15 案例5,上M10拉高出货