前几题都是水题。。比赛地址:https://atcoder.jp/contests/abc120/tasks
C Unification
题意:
给你一段字符串, 只有0,1两个数,如果两个相邻的数不同,那么可以把这两个数字消掉,然后前后的两个字符成为相邻的字符,问一共可以消掉多少个。
思路:
只有这个字符串存在不同的字符就可以消掉,所以答案就是0跟1数量最少的那个字符数量*2;
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxn = 2e5 + 5;
char str[maxn];
int main()
{
while(~scanf("%s", str))
{
int len = strlen(str), cnt0 = 0, cnt1 = 0;
for(int i = 0 ; i < len; i++)
if(str[i] == '0') cnt0+&