http://codeforces.com/problemset/problem/1009/B B. Minimum Ternary String time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a ternary string (it is a string which consists only…
B. Minimum Ternary String time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a ternary string (it is a string which consists only of characters '0', '1' and '2'). You can swap an…
Minimum Ternary String time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a ternary string (it is a string which consists only of characters '0', '1' and '2'). You can swap any t…
You are given a ternary string (it is a string which consists only of characters '0', '1' and '2'). You can swap any two adjacent (consecutive) characters '0' and '1' (i.e. replace "01" with "10" or vice versa) or any two adjacent (con…
题目链接:http://codeforces.com/contest/1009/problem/B 解题心得: 题意就是给你一个只包含012三个字符的字符串,位置并且逻辑相邻的字符可以相互交换位置,就是相邻的01交换,12交换,不可以02交换.最后需要输出字典序最小的字符串. 其实想想就很容易明白在字符串中1是可以随便移动的,所以可以把字符串中的1全删除,就只剩下02两种字符,这两种字符的相对位置不可以改变.然后把所有的1插在第一个02之间. #include <bits/stdc++.h>…
题意 给你一个只含有0,1,2的字符串,你可以将"01"变为"10","10"变为"01","12"变为"21","21"变为"12",问通过变换可以得到的字典序最小的串是什么? 题解 一开始天真的以为,我把所有的"10"变为"01",和所有的"21"变为"12"即可.…
题目传送门:http://codeforces.com/contest/957/problem/D 题意大致是这样的:有一个水池,每天都有一个水位(一个整数).每天都会在这一天的水位上划线(如果这个水位已经被划线了,那么不划线). 现在告诉你每天能看见的线条mi(就是高于水面的,刚好在水面的不算),设di为第i天水面以下的线条数(刚好在水面的不算),求(d1+d2+d3....dn)的最小值. 解析: 我们设第i天有ki条水位线,容易得到: 移项后,将d留在右边,我们发现mi和n都是固定的,所以…
C. Meaningless Operations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Can the greatest common divisor and bitwise operations have anything in common? It is time to answer this question.…
E. Vanya and Field time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vanya decided to walk in the field of size n × n cells. The field contains m apple trees, the i-th apple tree is at the c…
You are given a string ss consisting of exactly nn characters, and each character is either '0', '1' or '2'. Such strings are called ternary strings. Your task is to replace minimum number of characters in this string with other characters to obtain…