题目传送门

 /*
题意:找到一个字符串p,使得它和s,t的不同的总个数相同
贪心:假设p与s相同,奇偶变换赋值,当是偶数,则有答案
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <iostream>
using namespace std; const int MAXN = 1e5 + ;
const int INF = 0x3f3f3f3f;
int p[MAXN];
char s[MAXN], t[MAXN]; int main(void) //Codeforces Round #303 (Div. 2) B. Equidistant String
{
//freopen ("B.in", "r", stdin); while (scanf ("%s%s", s+, t+) == )
{
memset (p, , sizeof (p));
int len = strlen (s+); bool flag = false;
for (int i=; i<=len; ++i)
{
if (s[i] == t[i]) p[i] = ;
else
{
if (flag) {p[i] = t[i] - ''; flag = !flag;}
else {p[i] = s[i] - ''; flag = !flag;}
}
}
if (flag) puts ("impossible");
else
{
for (int i=; i<=len; ++i)
printf ("%d", p[i]);
puts ("");
}
} return ;
}

贪心 Codeforces Round #303 (Div. 2) B. Equidistant String的更多相关文章

  1. Codeforces Round #303 (Div. 2) B. Equidistant String 水题

    B. Equidistant String Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/54 ...

  2. 水题 Codeforces Round #303 (Div. 2) D. Queue

    题目传送门 /* 比C还水... */ #include <cstdio> #include <algorithm> #include <cstring> #inc ...

  3. DP Codeforces Round #303 (Div. 2) C. Woodcutters

    题目传送门 /* 题意:每棵树给出坐标和高度,可以往左右倒,也可以不倒 问最多能砍到多少棵树 DP:dp[i][0/1/2] 表示到了第i棵树时,它倒左或右或不动能倒多少棵树 分情况讨论,若符合就取最 ...

  4. 水题 Codeforces Round #303 (Div. 2) A. Toy Cars

    题目传送门 /* 题意:5种情况对应对应第i或j辆车翻了没 水题:其实就看对角线的上半边就可以了,vis判断,可惜WA了一次 3: if both cars turned over during th ...

  5. 贪心 Codeforces Round #288 (Div. 2) B. Anton and currency you all know

    题目传送门 /* 题意:从前面找一个数字和末尾数字调换使得变成偶数且为最大 贪心:考虑两种情况:1. 有偶数且比末尾数字大(flag标记):2. 有偶数但都比末尾数字小(x位置标记) 仿照别人写的,再 ...

  6. 贪心 Codeforces Round #301 (Div. 2) B. School Marks

    题目传送门 /* 贪心:首先要注意,y是中位数的要求:先把其他的都设置为1,那么最多有(n-1)/2个比y小的,cnt记录比y小的个数 num1是输出的1的个数,numy是除此之外的数都为y,此时的n ...

  7. 贪心 Codeforces Round #297 (Div. 2) C. Ilya and Sticks

    题目传送门 /* 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 */ #include <cstdio ...

  8. 贪心 Codeforces Round #304 (Div. 2) B. Soldier and Badges

    题目传送门 /* 题意:问最少增加多少值使变成递增序列 贪心:排序后,每一个值改为前一个值+1,有可能a[i-1] = a[i] + 1,所以要 >= */ #include <cstdi ...

  9. 找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones

    题目传送门 /* 找规律/贪心:ans = n - 01匹配的总数,水 */ #include <cstdio> #include <iostream> #include &l ...

随机推荐

  1. php浏览次数累加代码

    <?php $count=0; if(file_exists("count.txt")) //判断是否存在count.txt文件 { $count=file_get_cont ...

  2. HDOJ1004 数组还要自己初始化

    #include <iostream> #include <stdio.h> #include "string.h"using namespace std; ...

  3. acd - 1427 - Nice Sequence(线段树)

    题意:一个由n个数组成的序列(序列元素的范围是[0, n]).求最长前缀 j .使得在这个前缀 j 中对于随意的数 i1 < i2.都满足随意的 m <= j.i1 在前 m 个数里出现的 ...

  4. mysql 发生系统错误1067

    一般是由配置文件错误语法不正确引起的,如my.ini本人在mysql mysql-5.6.29-winx64 配置过程中遇到“发生系统错误1067”主要由于下面两个目录写的格式不正确引起的正确写法如下 ...

  5. 常用bluetooth协议

    HFP: HFP(Hands-free Profile),让蓝牙设备可以控制电话,如接听.挂断.拒接.语音拨号等,拒接.语音拨号要视蓝牙耳机及电话是否支持. HSP: HSP 描述了 Bluetoot ...

  6. 使用JavaScript访问XML数据

    在本篇文章中,我们将讲述如何在IE中使用ActiveX功能来访问并解析XML文档,由此允许网络冲浪者操纵它们.这一网页将传入并运行脚本的初始化.你一定确保order.xml文档与jsxml.html在 ...

  7. Extjs散记

    在元素的后面添加文字,如 汇率:_____%   { fieldLabel : '输入框', xtype : 'textfield', anchor : '80%', listeners: {     ...

  8. Apostrophe not preceded by \

    编辑strings.xml的时候, <string name="start">Let's get started!</string> 报错说:“Apostr ...

  9. BZOJ_2017_[Usaco2009 Nov]硬币游戏_博弈论+DP

    BZOJ_2017_[Usaco2009 Nov]硬币游戏_博弈论+DP Description 农夫约翰的奶牛喜欢玩硬币游戏,因此他发明了一种称为“Xoinc”的两人硬币游戏. 初始时,一个有N(5 ...

  10. Git如何删除自己创建的项目

    版本管理器第二行最右边,找到倒三角,下面的Edit Project,拖动鼠标到最下面,Remove project ,弹出框Confirmation required里面输入项目名字,如项目名字为“w ...