题解 | 打牌

打牌

https://www.nowcoder.com/practice/82442ee76977479e8ab4b88dfadfca9f

#include <iostream>
#include<string>
using namespace std;

int main() {
    string str1, str2;
    while (cin >> str1 >> str2) {
        
        if (str2.size() < 5) {
            bool big = false;
            for (int i = 0, j = 0; i < str1.size() - 1;i++) {
                if (str1[i] > str2[0]) {
                    j = i;
                    while (str1[j] == str1[i])j++;
                    if (j - i >= str2.size()) {
                        big = true;
                    }
                    //if (j == str1.size() - 1)break;
                    i = j-1;
                }
            }
            if(big) puts("YES");
            else puts("NO");
        }
        else {
            bool visit[10] = { 0 };
            int res = 0;
            int count = 0;
            int last = -1;
            for (int j = str1.size() - 1; j >= 0; j--) {
                if (!visit[str1[j]-'0'] && str1[j] > str2[0]) {
                    if (last != str1[j] - '0'+1)count = 0;
                    last = str1[j] - '0';
                    count++;
                    res = max(res, count);
                    visit[str1[j] - '0'] = true;
                }
            }
            if (res >= str2.size()) {
                puts("YES");
            }
            else puts("NO");
        }
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

09-08 20:19
门头沟学院 Java
如标题所见,想问一下27届大三想找实习9月份到10月份的机会多嘛?害怕错过最好的时机,鼠鼠也想占一个实习的好坑位
牛客20646354...:第一份实习还是看运气吧,我当时第一段实习靠点评和外卖找了好久才找到的。有了第一段后面就好找一些了,万事开头难
不给转正的实习,你还去吗
点赞 评论 收藏
分享
09-01 11:31
门头沟学院 Java
buul:七牛云的吧,感觉想法是好的,但是大家没那么多时间弄他这个啊。。。不知道的还以为他是顶尖大厂呢还搞比赛抢hc,只能说应试者的痛苦考察方是无法理解的,他们只会想一出是一出
点赞 评论 收藏
分享
牛客59349152...:没有让你做出个前后端页面,然后又不要你就知足了吧😂
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务