题意 给你一个只含有0,1,2的字符串,你可以将"01"变为"10","10"变为"01","12"变为"21","21"变为"12",问通过变换可以得到的字典序最小的串是什么? 题解 一开始天真的以为,我把所有的"10"变为"01",和所有的"21"变为"12"即可.…
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…
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…
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…
题目链接:http://codeforces.com/contest/1009/problem/B 解题心得: 题意就是给你一个只包含012三个字符的字符串,位置并且逻辑相邻的字符可以相互交换位置,就是相邻的01交换,12交换,不可以02交换.最后需要输出字典序最小的字符串. 其实想想就很容易明白在字符串中1是可以随便移动的,所以可以把字符串中的1全删除,就只剩下02两种字符,这两种字符的相对位置不可以改变.然后把所有的1插在第一个02之间. #include <bits/stdc++.h>…
题意:有两个人玩游戏,游戏规则如下:有一个长度为n的字符串,这个字符串由 . 和 X 构成,Alice可以选择a个连续的 . 把它们变成X, Bob可以选择连续的b个 . 把它们变成X.题目中保证a > b, Alice先手,问双方都不放水的情况下谁会赢? 思路:注意到a > b这个关键条件,这个条件是本题的突破口.因为a > b, 我们可以把由 . 构成的区间分成四类:1:长度小于b的区间,这种区间谁都无法填充,不用考虑.2:长度大于等于b小于a的区间,这种区间只有b可以填充.3:长度…
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…
题目链接:Balanced Ternary String 题目大意:给一个字符串,这个字符串只由0,1,2构成,然后让替换字符,使得在替换字符次数最少的前提下,使新获得的字符串中0,1,2 这三个字符的数目相同,并且新获得的字符串的字典序要尽可能的小: 直接数组做法:暴力遍历 /* */ # include <bits/stdc++.h> using namespace std; typedef long long ll; int n; ]; string s; int main() { io…
Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Description Input Output Print exactly one integer — the beauty of the product of the strings. Sample Input 3aba Sample Output 3 题解:这个题的思维难度其实不大,需要维护什么东西很容易想到,或…