[思路贪心]UVa12545 - Bits Equalizer
来源:互联网 发布:知锦教育龙腾 编辑:程序博客网 时间:2024/06/04 19:38
先把0变1
然后把变的这一组的_0_1与对应_1_?变
#include<bits/stdc++.h>using namespace std;const int maxn = 210;char s[maxn],s0[maxn];int solve(int n){ int sum,_0_1,_1_0,_1_q,_0_q,cnt=0; sum=_0_1=_1_0=_1_q=_0_q=cnt=0; for(int i=0;i<n;i++){ if(s0[i]=='1'&&s[i]=='?') ++sum,++_1_q; if(s0[i]=='0'&&s[i]=='?') ++sum,++_0_q; if(s0[i]=='1'&&s[i]=='0') ++sum,++_1_0; if(s0[i]=='0'&&s[i]=='1') ++sum,++_0_1; } int t=min(_1_0,_0_1); cnt+=t,_0_1-=t,sum-=2*t; t=min(_1_q,_0_1); cnt+=2*t,_0_1-=t,sum-=2*t; if(_0_1) return -1; return cnt+sum;}int main(){ int t,tt=0; scanf("%d",&t); while(t--){ scanf("%s%s",s,s0); printf("Case %d: %d\n",++tt,solve((int)strlen(s0))); } return 0;}find out what you passion is,what make you happy
what you love doing
pursue with everything you have,work harder than anybody else
know that life doesn't always go as planed
we all have dreams,we all have visions,we can do with our lives
but there would be a lot of times when it doesn't the way we want to,
and there happens everybody,but it not realy about how
what is important is how you respon to this situations,you know
that's the persevere,so when you go through life struggles,dont
complain,dont grumble everybody else ,stay positive,work harder than
everybody else ,put yourself the position on succeed
you are the only one.
0 0
- [思路贪心]UVa12545 - Bits Equalizer
- [UVA12545]Bits Equalizer[贪心]
- UVA12545 Bits Equalizer(脑洞)
- UVA12545 Bits Equalizer
- UVA12545:Bits Equalizer(比特变换器)
- 比特变换器 Bits Equalizer,SWERC 2012 ,UVA12545
- 12545-Bits Equalizer贪心
- 12545 - Bits Equalizer(贪心?)
- UVA - 12545 Bits Equalizer 贪心
- uva 12545 Bits Equalizer(贪心)
- UVA 12545 Bits Equalizer(模拟+贪心)
- UVa 12545 - Bits Equalizer(贪心)
- UVa:12545 Bits Equalizer(贪心)
- UVA - 12545 Bits Equalizer (贪心)
- UVA 12545 Bits Equalizer(瞎搞 贪心)
- UVa 12545 Bits Equalizer——贪心
- 习题8-3 比特变换器(Bits Equalizer, SWERC 2012, UVa12545)
- uva12545(贪心)
- Fragment Or DialogFragment Can not perform this action after onSaveInstanceState
- HashCode和equal方法的区别和联系
- java 在linux下获取的时间是美国时间,解决办法
- 一、ArrayList概述
- Mysql 列转行统计查询 、行转列统计查询
- [思路贪心]UVa12545 - Bits Equalizer
- win8.1安装apache+php
- 1.将数组A中的内容和数组B中的内容进行交换。(数组一样大)
- UVa11491 - Erasing and Winning
- 获取一个数二进制序列中所有的偶数位和奇数位,分别输出二进制序列。
- POJ1860
- dell 1520 win7 x64 触摸板驱动 synaptics touchpad 16.2.10.3
- 失眠夜
- 1