题目链接: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. mysql 远程登录 设置

    1.在服务器上通过命令行或客户端登录mysql:2.执行以下sql:GRANT ALL PRIVILEGES ON 开放权限的数据库.* TO 用户名@"%" IDENTIFIED ...

  2. LINUX的DNS怎么设置?linux下如何修改DNS地址

    LINUX的DNS怎么设置?linux下如何修改DNS地址 https://jingyan.baidu.com/article/870c6fc32c028eb03fe4be30.html Linux下 ...

  3. python 调用阿里云服务器api创建服务器

    首先安装阿里云SDK pip install aliyun-python-sdk-core pip install aliyun-python-sdk-ecs 可以配合jenkins传递参数 #!/u ...

  4. 【LeetCode每天一题】Swap Nodes in Pairs

    Given a linked list, swap every two adjacent nodes and return its head. You may not modify the value ...

  5. async和await用法(Task)

    原文:async和await用法 要理解async和await的用法,首先要了解Task相关知识,这里不做说明,因为这不是本文的重点. 如果你已经对Task很了解,那么如何使用async和await, ...

  6. 利用TensorFlow实现多元线性回归

    利用TensorFlow实现多元线性回归,代码如下: # -*- coding:utf-8 -*- import tensorflow as tf import numpy as np from sk ...

  7. android 注入so

    https://www.52pojie.cn/thread-564459-1-1.html

  8. C#使用HttpWebRequest与HttpWebResponse模拟用户登录

    模拟艺龙旅游网登录 想模拟登录,首先整理一下流程 1.通过360浏览器(IE,火狐等等)F12开发人员工具抓到相关数据 2.获取验证码(拿到cookie),登录时也需要使用 3.登录 -------- ...

  9. Ubuntu 16.04卸载一些不必要的预装软件

    卸载libreoffices ~$ sudo apt-get remove libreoffice-common 卸载Amazon的链接 ~$ sudo apt-get remove unity-we ...

  10. Linux的文件最大连接数

    [最大连接数]Linux的文件最大连接数   查看当前操作系统连接数设置 ulimit -a ==================================== 修改服务器最大连接数 vim / ...