AtCoder Beginner Contest 082 B - Two Anagrams
题目链接: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=b1, a2=b2, ..., aN=bN.
- There exists i (1≤i≤N,M) such that a1=b1, a2=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
yx
axy
Sample Output 1
Yes
We can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.
Sample Input 2
ratcode
atlas
Sample Output 2
Yes
We can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.
Sample Input 3
cd
abc
Sample Output 3
No
No matter how we rearrange cd and abc, we cannot achieve our objective.
Sample Input 4
w
ww
Sample Output 4
Yes
Sample Input 5
zzz
zzz
Sample Output 5
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的更多相关文章
- AtCoder Beginner Contest 082 A - Round Up the Mean
题目链接:https://abc082.contest.atcoder.jp/tasks/abc082_a Time limit : 2sec / Memory limit : 256MB Score ...
- AtCoder Beginner Contest 100 2018/06/16
A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...
- AtCoder Beginner Contest 052
没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...
- AtCoder Beginner Contest 053 ABCD题
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...
- AtCoder Beginner Contest 136
AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...
- AtCoder Beginner Contest 137 F
AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...
- AtCoder Beginner Contest 076
A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takaha ...
- AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】
AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...
- AtCoder Beginner Contest 064 D - Insertion
AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...
随机推荐
- 防止SQL注入的6个要点
SQL注入,就是通过把SQL命令插入到Web表单递交或输入域名或页面请求的查询字符串,最终达到欺骗服务器执行恶意的SQL命令.防止SQL注入,我们可以从以下6个要点来进行: 1.永远不要信任用户的输入 ...
- what's the python之异常处理
what's the 异常 python程序中会出现异常,即bug.若出现异常程序就报错,异常之后的代码就不会继续往下执行,这是一个正常程序不允许出现的,但是在某些程序交互的时候难免会因为用户输入问题 ...
- 008-spring cache-缓存实现-03-springboot redis实现
1.window下redis安装 https://www.cnblogs.com/bjlhx/p/7429811.html 2.pom <!-- 缓存 --> <dependency ...
- PHP MYSQL 临时表的使用
/** * 临时表:用于获取爱鸽登录分类数量 */ $temporaryTableName = uniqid('temporary_'); $model = M(); $model->execu ...
- NewWord
identification: 鉴定,识别; 验明; 身份证明; 认同; peer:PEER-TO-PEER:同等延迟机制.根据网络中共享资源方式的不同,局域网有两种组织形式 filters: n. ...
- webpack使用六
插件(Plugins) 插件(Plugins)是用来拓展Webpack功能的,它们会在整个构建过程中生效,执行相关的任务. Loaders和Plugins常常被弄混,但是他们其实是完全不同的东西,可以 ...
- vbs调用bat 隐藏bat运行时的黑框
//新建文本文件 ,保存为后缀为bat.如:startBAT.vbs public const vbQuote="""" temp="C:\A_WOR ...
- Linux的文件最大连接数
[最大连接数]Linux的文件最大连接数 查看当前操作系统连接数设置 ulimit -a ==================================== 修改服务器最大连接数 vim / ...
- MindMaster学习笔记
参考博客 http://blog.sina.com.cn/u/6406591976 作者名叫“MindMaster思维导图的博客 ”写了一系列关于思维导图的博客,可以去学习下. 1.其中有一篇比较详细 ...
- 去掉idea中竖线
1.现象如下: 2.解决办法. 3.解决后如下: