zoukankan      html  css  js  c++  java
  • AtCoder Beginner Contest 082 B

    题目链接: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

    补漏洞
     1 #include <iostream>
     2 #include <cstdio>
     3 #include <algorithm>
     4 #include <stack>
     5 #include <string>
     6 #include <cstring>
     7 #include <cmath>
     8 #include <cstdio>
     9 using namespace std;
    10 char a[101];
    11 char b[101];
    12 int main()
    13 {
    14     while(scanf("%s%s",&a,&b)!=EOF){
    15         int la=strlen(a);
    16         int lb=strlen(b);
    17         sort(a,a+la);
    18         sort(b,b+lb);
    19         if(a[0]<b[lb-1]) cout<<"Yes"<<endl;
    20         else if(a[0]>b[lb-1]) cout<<"No"<<endl;
    21         else{
    22             if(a[0]==a[la-1]&&b[0]==b[lb-1]&&a[0]==b[0]){
    23                 if(lb>la) cout<<"Yes"<<endl;
    24                 else cout<<"No"<<endl;
    25                 continue;
    26             }
    27             int k=0;
    28             for(int i=0;i<la;i++){
    29                 for(int j=0;j<lb;j++){
    30                     if(b[j]>a[i]){
    31                         k++;
    32                         break;
    33                     }
    34                 }
    35             }
    36             if(k==la) cout<<"Yes"<<endl;
    37             else cout<<"No"<<endl;
    38         }
    39     }
    40     return 0;
    41 }
  • 相关阅读:
    appium 环境安装windows
    解决windows7无法连接CentOS7系统中oracle问题:ORA-12514 TNS 监听程序当前无法识别
    linux系统(CentOS7)虚拟机上安装oracle 11g,解决oracle图形界面卡住无法点击next问题
    python自动化测试框架学习
    VSCode + GDBServer 远程调试C/C++流水账
    IDEA 16注册
    VS2008非托管C++调用wcf(WebService)服务
    python 从数据库表生成model
    2015年工作总结
    dlib库学习之一
  • 原文地址:https://www.cnblogs.com/wydxry/p/8075879.html
Copyright © 2011-2022 走看看