题目传送门

 /*
题意:找到一个字符串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. nlp_tool

    http://www.afenxi.com/post/9700 11款开放中文分词引擎大比拼 附录评测数据地址http://bosonnlp.com/dev/resource 各家分词系统链接地址Bo ...

  2. 新产品为了效果,做的比較炫,用了非常多的图片和JS,所曾经端的性能是非常大的问题,分篇记录前端性能优化的一些小经验。

    第一篇:HTTPserver 因tomcat处理静态资源的速度比較慢,所以首先想到的就是把全部静态资源(JS,CSS,image,swf) 提到单独的server,用更加高速的HTTPserver,这 ...

  3. Qt & opencv 学习(一)

    Qt也没怎么系统学过,opencv也没系统学过.慢慢来,一步一步弄清楚吧. 天嵌科技有个文档,先去看这个文档,主要是开发环境的配置.文档名字就是QT应用程序开发手册-20150918.pdf.在QT里 ...

  4. field 属性操作

    首先必须明一点 Field类主要是用来辅助获取和操作类的属性的! 1.怎么通过反射获取类的属性 先来看JDK提供的方法有如下几种: a)Class.getDeclaredField(String na ...

  5. spring核心框架体系结构(各个jar包作用)

    转自:https://blog.csdn.net/sunchen2012/article/details/53939253 弄懂spring就是弄懂spring各个jar包的作用 spring的jar ...

  6. Vue 中的受控与非受控组件

    Vue 中的受控与非受控组件 熟悉 React 的开发者应该对"受控组件"的概念并不陌生,实际上对于任何组件化开发框架而言,都可以实现所谓的受控与非受控,Vue 当然也不例外.并且 ...

  7. 前端模块化开发的规范:AMD与CDM

    AMD, 异步模块定义. CMD,通用模块规范.

  8. access函数的使用检查文件的权限【学习笔记】

    #include "apue.h" #include <fcntl.h> int main(int argc,char **argv) { ) err_quit(&qu ...

  9. HDU1964 Pipes —— 插头DP

    题目链接:https://vjudge.net/problem/HDU-1964 Pipes Time Limit: 5000/1000 MS (Java/Others)    Memory Limi ...

  10. Android 走向MD的配色风格

    这是一些google官方推出的推荐色值 下面补充上对应的xml文件,省得大家再去自己写 <?xml version="1.0" encoding="utf-8&qu ...