Codeforces Round #568 Div.2

Posted zlrrrr

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #568 Div.2相关的知识,希望对你有一定的参考价值。

A. Ropewalkers

技术图片
#include <bits/stdc++.h>
using namespace std;
 
int num[5];
int d;
 
int main() {
    for(int i = 0; i < 3; i ++)
        scanf("%d", &num[i]);
    scanf("%d", &d);
    
    sort(num, num + 3);
    int ans = 0;
    
    if(num[1] - num[0] < d)
        ans += d - num[1] + num[0];
    if(num[2] - num[1] < d)
        ans += d - num[2] + num[1];
    
    printf("%d
", ans);
    
    return 0;
}
View Code

B. Email from Polycarp

技术图片
#include <bits/stdc++.h>
using namespace std;
int T;
string s, t;

bool isSubsequence(string s, string t) {
    int ls = s.length(), lt = t.length();
    if(!ls) return true;
    if(!lt && ls) return false;
     
    int pos = 0, temp = 0;
    char c = s[pos];
    while(pos <= ls && temp <= lt) {
        if(s[pos] == t[temp]) {
            c = s[pos];
            pos ++;
        } else {
            if(t[temp] != c) return false;
        }
        temp ++;
    }
    return pos == ls + 1;
}

int main() {
    scanf("%d", &T);
    while(T --) {
        cin >> s >> t;
        if(isSubsequence(s, t)) printf("YES
");
        else printf("NO
");
    }
    return 0;
}
View Code

被病毒吓到不敢出门 QAQ 废宅好几天重于开始干活辽 接下来打算看书去辽 为开工上班做准备!

以上是关于Codeforces Round #568 Div.2的主要内容,如果未能解决你的问题,请参考以下文章

Codeforces Round #568 Div.2

codeforces 568a//Primes or Palindromes?// Codeforces Round #315 (Div. 1)

Codeforces Round #568 (Div. 2) F - Two Pizzas (状态压缩,暴力)

Codeforces Round #568 (Div. 2) G1. Playlist for Polycarp (easy version) (状压dp)

Codeforces Round #705 (Div. 2)

Codeforces Round #774 (Div. 2)