codeforces1437专题

Codeforces1437 B. Reverse Binary Strings

You are given a string 𝑠 of even length 𝑛. String 𝑠 is binary, in other words, consists only of 0’s and 1’s. String 𝑠 has exactly 𝑛2 zeroes and 𝑛2 ones (𝑛 is even). In one operation you can r

Codeforces1437 D. Minimal Height Tree(BFS序)

题意: 给出一颗树的BFS遍历结果,从结点1开始,每个结点叶子按编号从小到大遍历。求出可能树的最小高度。 思路: 为了让这棵树高度尽可能小,我们要使得每个结点的儿子尽可能多。所以直接遍历a数组,如果当前结点编号大于上一个,那就将此结点作为当前父亲节点儿子,否则就作为一个新的根节点。用队列维护待选父亲节点。 #include<cstdio>#include<cmath>#include<al