题目传送门

 /*
题意:找到一个字符串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. EF中 Code-First 方式的数据库迁移

    原文链接:http://www.c-sharpcorner.com/UploadFile/3d39b4/code-first-migrations-with-entity-framework/ 系列目 ...

  2. css盒子模型详解一

    什么是CSS的盒子模式呢?为什么叫它是盒子?先说说我们在网页设计中常听的属性名:内容(content).填充(padding).边框(border).边界(margin), CSS盒子模式都具备这些属 ...

  3. 禅道——Linux服务器部署禅道

    前言 2019年6月14日 22:01:24 看看时间我知道,我离猝死依然不远~ 禅道是什么 | 禅道是专业的研发项目管理软件 禅道的官网 | https://www.zentao.net/ 禅道开源 ...

  4. Oracle:datafile删除后,重启server报ORA-01110

    模拟实验: 创建一个表空间后,直接把数据文件删除了:然后重启server. 1. create tablespace w56 datafile '/u01/app/oracle/product/10. ...

  5. Loadrunner11打开WebTours只显示头部解决办法

    1.遇到这种情况,先查看一下路径HP\LoadRunner\WebTours下的cgierr日志中是否有错误,比如Can't open perl script "D:\Program&quo ...

  6. NOIP提高组2006-金明的预算方案

    链接 分析:依赖型0-1背包问题,对于一个主件,可以挂0个,1个,2个附件,所以最终为4种状态情况下的最大值. #include "iostream" #include " ...

  7. BackTrack5(BT5)各版本下载

    BT5R3(最新版本)http://www.nigesb.com/backtrack-5-r3-released.html  BT5R2KDE版32位: http://ftp.halifax.rwth ...

  8. 数据库sql互转(oracle转mysql为例子)

    转自: https://blog.csdn.net/sinat_32366329/article/details/76402059 在PowerDesinger里找到 File -->> ...

  9. list转json的一些问题

    利用JSONArray转换list 定义的model: package com.yds.model; import java.util.Date; public class DeviceHistory ...

  10. Hadoop 三大调度器源码分析及编写自己的调度器

    如要转载,请注上作者和出处.  由于能力有限,如有错误,请大家指正. 须知: 我们下载的是hadoop-2.7.3-src 源码. 这个版本默认调度器是Capacity调度器. 在2.0.2-alph ...