原题链接:http://codeforces.com/gym/100203/attachments/download/1702/statements.pdf

题解

考虑到交换可以减少一次操作,那么可以的话就尽量交换,设问号的个数是z,上面是1下面是0的个数是x,反过来的是y,那么最后的答案就是z+min(x,y)+abs(x-y)。代码是队友写的,我是嘴炮流选手。

代码

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <queue>
#include <ctime>
#include <cmath>
#include <set>
#include <stack>
#include <map>
#define eps 1e-10
#define MAXN 500010
#define INF 2*0x3f3f3f3f
using namespace std; int T;
char str1[], str2[]; int main() {
//freopen("in.in", "r", stdin);
//freopen("out.out", "w", stdout);
scanf("%d", &T);
for (int cas = ; cas <= T; cas++) {
scanf("%s %s", str1, str2);
int len = strlen(str1);
int x = , y = , z = ;
for (int i = ; i < len; i++) if (str1[i] != '') x++;
for (int i = ; i < len; i++) if (str2[i] != '') y++;
if (x < y) printf("Case %d: %d\n", cas, -);
else {
x = y = z = ;
for (int i = ; i < len; i++) {
if (str1[i] == '?') z++;
else if (str1[i] == '' && str2[i] == '') x++;
else if (str1[i] == '' && str2[i] == '') y++;
}
printf("Case %d: %d\n", cas, z + min(x, y) + abs(y - x));
}
}
return ;
}

Codeforces Gym 100203E bits-Equalizer 贪心的更多相关文章

  1. Codeforces Gym 100203E E - bits-Equalizer 贪心

    E - bits-EqualizerTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest ...

  2. Codeforces Gym 100269E Energy Tycoon 贪心

    题目链接:http://codeforces.com/gym/100269/attachments 题意: 有长度为n个格子,你有两种操作,1是放一个长度为1的东西上去,2是放一个长度为2的东西上去 ...

  3. codeforces Gym 100338E Numbers (贪心,实现)

    题目:http://codeforces.com/gym/100338/attachments 贪心,每次枚举10的i次幂,除k后取余数r在用k-r补在10的幂上作为候选答案. #include< ...

  4. CodeForces Gym 100685I Innovative Business (贪心)

    题意:给定一条路的长和宽,然后给你瓷砖的长和宽,你只能横着或者竖着铺,也可以切成片,但是每条边只能对应一条边,问你最少要多少瓷砖. 析:先整块整块的放,然后再考虑剩下部分,剩下的再分成3部分,先横着, ...

  5. Codeforces GYM 100876 J - Buying roads 题解

    Codeforces GYM 100876 J - Buying roads 题解 才不是因为有了图床来测试一下呢,哼( 题意 给你\(N\)个点,\(M\)条带权边的无向图,选出\(K\)条边,使得 ...

  6. Codeforces Gym 101252D&&floyd判圈算法学习笔记

    一句话题意:x0=1,xi+1=(Axi+xi%B)%C,如果x序列中存在最早的两个相同的元素,输出第二次出现的位置,若在2e7内无解则输出-1. 题解:都不到100天就AFO了才来学这floyd判圈 ...

  7. Codeforces gym 101343 J.Husam and the Broken Present 2【状压dp】

     2017 JUST Programming Contest 2.0 题目链接:Codeforces gym 101343 J.Husam and the Broken Present 2 J. Hu ...

  8. CodeForces Gym 100213F Counterfeit Money

    CodeForces Gym题目页面传送门 有\(1\)个\(n1\times m1\)的字符矩阵\(a\)和\(1\)个\(n2\times m2\)的字符矩阵\(b\),求\(a,b\)的最大公共 ...

  9. uva12545 Bits Equalizer

    uva12545 Bits Equalizer You are given two non-empty strings S and T of equal lengths. S contains the ...

随机推荐

  1. 面向对象之元类(metaclass)

    一.前言: 要搞懂元类必须要搞清楚下面几件事: 类创建的时候,内部过程是什么样的,也就是我们定义类class 类名()的过程底层都干了些啥 类的调用即类的实例化过程的了解与分析 我们已经知道元类存在的 ...

  2. jmeter switch controller

    工作方式: Switch控制器通过给该控制器中的Value赋值,来指定运行哪个采样器.有两种赋值方式: 1.第一种是数值,Switch控制器下的子节点从0开始计数,通过指定子节点所在的数值来确定执行哪 ...

  3. python基础学习笔记——异常处理

    异常处理流程图 一,异常和错误 part1:程序中难免出现错误,而错误分成两种 1.语法错误(这种错误,根本过不了python解释器的语法检测,必须在程序执行前就改正) #语法错误示范一 if #语法 ...

  4. syntax error, error in :'e id=1?', expect QUES, actual QUES pos 66, line 1, column 66, token QUES错误

    在查询数据库的时候报了下面的异常: syntax error, error in :'e id=1?', expect QUES, actual QUES pos 66, line 1, column ...

  5. webdriver高级应用- 操作日期控件

    1. 通过点击的方式操作日期控件 #encoding=utf-8 from selenium import webdriver import unittest, time, traceback fro ...

  6. postgres 用户管理

    首次安装完成 pg 数据库后,会默认自带一个用户, 用户名: postgres 密码: postgres 可以使用命令 \du 查看数据库用户 创建新用户: create user dev with ...

  7. javascript学习笔记-数据类型

    一 数据类型 基本类型:undefined,null,boolean,number,string     保存在栈内存中     占用空间固定        变量直接从栈内存中存取的是该值 引用类型: ...

  8. google chrome & preferences & languages

    google chrome & preferences & languages language settings https://www.google.com/preferences ...

  9. iOS----精品开源库-开发强力助攻

    30个精品iOS开源库,超强助攻 你不会想错过他们,真的. 我爱开源.  文章的尾部你会看到一个太长不看的版本——一个简单的列表,只有标题和到项目的链接.如果你发现这篇文章是有用的,把它和你的iOS开 ...

  10. 【bzoj1778】[Usaco2010 Hol]Dotp 驱逐猪猡 矩阵乘法+概率dp+高斯消元

    题目描述 奶牛们建立了一个随机化的臭气炸弹来驱逐猪猡.猪猡的文明包含1到N (2 <= N <= 300)一共N个猪城.这些城市由M (1 <= M <= 44,850)条由两 ...