贪心 Codeforces Round #303 (Div. 2) B. Equidistant String
/*
题意:找到一个字符串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的更多相关文章
- Codeforces Round #303 (Div. 2) B. Equidistant String 水题
B. Equidistant String Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/54 ...
- 水题 Codeforces Round #303 (Div. 2) D. Queue
题目传送门 /* 比C还水... */ #include <cstdio> #include <algorithm> #include <cstring> #inc ...
- DP Codeforces Round #303 (Div. 2) C. Woodcutters
题目传送门 /* 题意:每棵树给出坐标和高度,可以往左右倒,也可以不倒 问最多能砍到多少棵树 DP:dp[i][0/1/2] 表示到了第i棵树时,它倒左或右或不动能倒多少棵树 分情况讨论,若符合就取最 ...
- 水题 Codeforces Round #303 (Div. 2) A. Toy Cars
题目传送门 /* 题意:5种情况对应对应第i或j辆车翻了没 水题:其实就看对角线的上半边就可以了,vis判断,可惜WA了一次 3: if both cars turned over during th ...
- 贪心 Codeforces Round #288 (Div. 2) B. Anton and currency you all know
题目传送门 /* 题意:从前面找一个数字和末尾数字调换使得变成偶数且为最大 贪心:考虑两种情况:1. 有偶数且比末尾数字大(flag标记):2. 有偶数但都比末尾数字小(x位置标记) 仿照别人写的,再 ...
- 贪心 Codeforces Round #301 (Div. 2) B. School Marks
题目传送门 /* 贪心:首先要注意,y是中位数的要求:先把其他的都设置为1,那么最多有(n-1)/2个比y小的,cnt记录比y小的个数 num1是输出的1的个数,numy是除此之外的数都为y,此时的n ...
- 贪心 Codeforces Round #297 (Div. 2) C. Ilya and Sticks
题目传送门 /* 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 */ #include <cstdio ...
- 贪心 Codeforces Round #304 (Div. 2) B. Soldier and Badges
题目传送门 /* 题意:问最少增加多少值使变成递增序列 贪心:排序后,每一个值改为前一个值+1,有可能a[i-1] = a[i] + 1,所以要 >= */ #include <cstdi ...
- 找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones
题目传送门 /* 找规律/贪心:ans = n - 01匹配的总数,水 */ #include <cstdio> #include <iostream> #include &l ...
随机推荐
- DataFactory 5.6注册码
一.DataFactory 5.6注册码 数据工厂5.6注册码如下,希望能帮助需求之人 AuthKey: 0-87093-23830-05141-17507 SiteMsg: FREELAND EVO ...
- HDU 3249 Test for job (有向无环图上的最长路,DP)
解题思路: 求有向无环图上的最长路.简单的动态规划 #include <iostream> #include <cstring> #include <cstdlib ...
- Serialization and deserialization are bottlenecks in parallel and distributed computing, especially in machine learning applications with large objects and large quantities of data.
Serialization and deserialization are bottlenecks in parallel and distributed computing, especially ...
- poj 1179 $Polygon$(断环成链)
Polygon \(solution:\) upd:还是多讲一下,这道题基本上可以说是一道思维题.一道结论题.一道考验你动态规划基本功是否扎实的题目.因为这道题的数据范围很小,思考一下总能想到断环成链 ...
- rails find find_by where
find根据id进行查询,像Product.find(3),查询语句是Product Load (0.1ms) SELECT "products".* FROM "pro ...
- VK Cup 2016 - Round 1 (Div. 2 Edition) C. Bear and Forgotten Tree 3
C. Bear and Forgotten Tree 3 time limit per test 2 seconds memory limit per test 256 megabytes input ...
- 如何用redis做到限制,一个手机号,1分钟内最多发一条,一天内最多10条
需要两个缓存 key名称 phone-busy,缓存1分钟 key名称 phone-send-count,缓存1天,每成功发送一条+1 发送的时候流程如下: 判断phone-busy是否存在,存在直接 ...
- js中获取时间new date()的用法 获取时间:
获取时间: 1 var myDate = new Date();//获取系统当前时间 获取特定格式的时间: 1 myDate.getYear(); //获取当前年份(2位) 2 myDate.getF ...
- chan
第一单元:分型.笔.线段 ?1 分型 一.分型.笔和线段所属范畴 缠师在<教你炒股票72:本ID已有课程的再梳理>中对缠论做过这样的说明“本ID的理论,本质上分两部分,一是形态学,二是动 ...
- 解决 git branch -a 无法全部显示远程的分支,只显示master分支
新建分支 若遇到 git branch -a 无法全部显示远程的分支,只显示master分支 可以通过 git fetch 将本地远程跟踪分支进行更新,与远程分支保持一致