Educational Codeforces Round 82 (Rated for Div. 2)

A

1必须和1相邻,把所有1和1之间的0去掉即可,就是统计1和1之间有多少个0

#include <iostream>
#include <cstdio>
#include <vector>
int main(){
    int T;
    read(T);
    while(T--){
        char s[105];
        cin >> s;
        int len = strlen(s);
        std::vector<int> v;
        for(int i = 0; i < len; i++){
            if(s[i] == '1')v.push_back(i);
        }
        int ans = 0;
        for(int i = 1; i < v.size(); i++){
            ans += v[i] - v[i - 1] - 1;
        }
        printf("%d\n",ans);
    }
    return 0;
}

B

好的天数是\(x = \lceil\frac{n}{2}\rceil\),那么优先考虑x
x天需要\(\lceil\frac{x}{g}\rceil\)个g天去完成,但是最后一个g天不一定用完,比如n = 10,g = 2,需要 2,2,1去完成
那么\((\lceil\frac{x}{g}\rceil - 1) * (g + b) + x - (\lceil\frac{x}{g}\rceil - 1) * g = x + (\lceil\frac{x}{g}\rceil - 1) * b\)就是完成质量好的项目的最小个数
然后这个答案与n进行比较,输出大的即可

#include <iostream>
#include <cmath>
int main(){
    int T;
    read(T);
    while(T--){
        ll n,g,b;
        cin >> n >> g >> b;
        ll x = ceil((double)n/2);
        ll t = ceil(double(x)/g);
        cout << max(n,x + (t - 1) * b) << endl;
    }
    return 0;
}

C

模拟一下,类似一个双端队列,先把给出的字符串的第一个字符加入队列,然后遍历字符串

#include <iostream>
#include <vector>
#include <array>
#include <cstring>
#include <string>
using namespace std;
int main(){
    int t;cin >> t;
    while(t--){
        string s;cin >> s;
        std::vector<char > kb(100,'\0');
        kb[50] = s[0];
        int index = 50;
        int l = 50,r = 50;
        bool pos = true;
        array<bool,26>seen = {0};
        seen[s[0] - 'a'] = true;
        for(int j = 1; j < s.length(); j++){
            char c = s[j];
            if(kb[index - 1] == c)
                index--;
            else if(kb[index + 1] == c)
                index++;
            else if(kb[index - 1] == '\0' && !seen[c - 'a'])
                --index,kb[index] = c;
            else if(kb[index + 1] == '\0' && !seen[c - 'a'])
                ++index,kb[index] = c;
            else{
                pos = false;
                break;
            }
            seen[c - 'a'] = true;
            l = min(l,index);r = max(r,index);
        }
        if(!pos){
            cout << "NO\n";
        }else{
            cout << "YES\n";
            for(int i = l; i <= r; i++)putchar(kb[i]);
            for(int i = 0; i < 26; i++){
                if(!seen[i])putchar((char)('a' + i));
            }
            putchar('\n');
        }
    }
    return 0;
}

然后,我太菜了,只做了3题

原文地址:https://www.cnblogs.com/Emcikem/p/12303041.html

时间: 2024-10-04 02:58:49

Educational Codeforces Round 82 (Rated for Div. 2)的相关文章

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars There are n pillars aligned in a row and numbered from 1 to n. Initially each pillar contains exactly one disk. The i-th pillar contains a disk having radius ai. You can move these disks

Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations

原文链接:https://www.cnblogs.com/xwl3109377858/p/11405773.html Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations You are given a sequence of n pairs of integers: (a1,b1),(a2,b2),…,(an,bn). This sequence is called bad if it is

Educational Codeforces Round 36 (Rated for Div. 2)

Educational Codeforces Round 36 (Rated for Div. 2) F. Imbalance Value of a Tree You are given a tree T consisting of n vertices. A number is written on each vertex; the number written on vertex i is ai. Let's denote the function I(x,?y) as the differ

Educational Codeforces Round 36 (Rated for Div. 2) 题解

Educational Codeforces Round 36 (Rated for Div. 2) 题目的质量很不错(不看题解做不出来,笑 Codeforces 920C 题意 给定一个\(1\)到\(n\)组成的数组,只可以交换某些相邻的位置,问是否可以将数组调整为升序的 解题思路 首先如果每个数都能通过交换到它应该到的位置,那么就可以调整为升序的. 但实际上交换是对称的,如果应该在的位置在当前位置前方的数都交换完成,那么整体就是排好序的,因为不可能所有不在相应位置的数都在相应位置的后方.

Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://codeforces.com/contest/985/problem/E Description Mishka received a gift of multicolored pencils for his birthday! Unfortunately he lives in a monochrome w

Educational Codeforces Round 55 (Rated for Div. 2)

Educational Codeforces Round 55 (Rated for Div. 2) 链接 A Vasya and Book 傻逼题..注意判边界. #include<cstdio> #include<cstring> #include<algorithm> #include<queue> #include<set> #include<map> #include<vector> #include<cm

Educational Codeforces Round 57 (Rated for Div. 2)

get人生第二场CF! 成绩:(exACM) rank858 AC3/7 Penalty57 rating1648(+52) 题目:Educational Codeforces Round 57 (Rated for Div. 2) 错题题解: D. Easy Problem E. The Top Scorer F. Inversion Expectation G. Lucky Tickets 原文地址:https://www.cnblogs.com/xht37/p/10198321.html

Educational Codeforces Round 58 (Rated for Div. 2)(待更新)

get人生第七场CF! 成绩:(exACM) rank AC3/7 Penalty104 rating() 题目:Educational Codeforces Round 58 (Rated for Div. 2) 错题题解: C. Division and Union 原文地址:https://www.cnblogs.com/xht37/p/10260260.html

Educational Codeforces Round 59 (Rated for Div. 2) DE题解

Educational Codeforces Round 59 (Rated for Div. 2) D. Compression 题目链接:https://codeforces.com/contest/1107/problem/D 题意: 给出一个n*(n/4)的矩阵,这个矩阵原本是一些01矩阵,但是现在四个四个储存进二进制里面,现在给出的矩阵为0~9以及A~F,表示0~15. 然后问这个矩阵能否压缩为一个(n/x)*(n/x)的矩阵,满足原矩阵中大小为x*x的子矩阵所有数都相等(所有子矩阵构