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 }
  • 相关阅读:
    借壳上市[来自百度]
    DIY协同办公平台(C/S)系列3之内部邮箱篇
    测试用例设计场景法
    客户关系管理系统提高企业对客户的响应速度
    CRM--销售管理的灵药
    CRM的两个问题
    需求分析是CRM系统实施的关键
    如何实施CRM客户关系管理系统
    CRM的三重境界
    企业需要更好的认识客户关系管理系统
  • 原文地址:https://www.cnblogs.com/shixinzei/p/8075879.html
Copyright © 2011-2022 走看看