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 ...
随机推荐
- Github上Laravel开源排行榜Star数61-90名
Github上Laravel开源排行榜Star数61-90名,罗列所有 Laravel 开源扩展包,含 Github Star 数量,下载数量和项目简介.默认排序是按Star数量从多到少来排 61.c ...
- SSIS--(1)
目标:两组数据比对,A 来源Excel ,B 来源 Sql server DB ,比对合并,取值放入目标 C 中 首先使用工具SSIS包 一,以数据源 A 为准核对B 中是否有A 的数据和计算等动作 ...
- Delphi启动数据库连接属性对话框
有时候需要客户端进行服务器连接配置,自己写配置窗体,总不如直接使用系统提供的使用方便快捷 例子一: //此例子有个坏处不管用户点了确定还是取消,均返回值 procedure TForm1.Button ...
- SQL语法集合
查询 select * from table limit 0,10 取0位置后面的10条记录 limit 0 表示从第一条记录开始 起始位置从0开始 10 表示取 ...
- 自定义安装visual studio 2010开发asp.net
VS2010的安装对于VS的安装大家肯定都熟悉,不过我在很多地方看到的是大家讲VS的全部组件都安装了,不但浪费磁盘空间,还降低了系统性能,除此之外,还有人安装了VS之后不知道顺手把MSDN安装上,害得 ...
- 帝国cms-tab
<ul class="intro_commenTab"> [e:loop={"select classname,classpath,classid from ...
- Java字符串复制
Java字符串复制 public boolean topicFilterMatch(String topicFilter, String topic) { if (topicFilter == nul ...
- tf中的run()与eval()【转载】
转自:https://blog.csdn.net/jiaoyangwm/article/details/79248535 1.eval() 其实就是tf.Tensor的Session.run() 的 ...
- [LeetCode] 613. Shortest Distance in a Line_Easy tag: SQL
Table point holds the x coordinate of some points on x-axis in a plane, which are all integers. Writ ...
- Util.FSUtils: Waiting for dfs to exit safe mode
有好几次,启动Hadoop和HBase之后,执行jps命令,已经看到有HMaster的进程, 但是进入到HBase的shell,执行一个命令,会出现下面的错误: ERROR: org.apache.h ...