题干:

You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears get bored. They come up with a game. First Alice and Bob each writes a 01-string (strings that only contain character "0" and "1") a and b. Then you try to turn a into b using two types of operations:

  • Write parity(a) to the end of a. For example, .
  • Remove the first character of a. For example, . You cannot perform this operation if a is empty.

You can use as many operations as you want. The problem is, is it possible to turn ainto b?

The parity of a 01-string is 1 if there is an odd number of "1"s in the string, and 0 otherwise.

Input

The first line contains the string a and the second line contains the string b (1 ≤ |a|, |b| ≤ 1000). Both strings contain only the characters "0" and "1". Here |x|denotes the length of the string x.

Output

Print "YES" (without quotes) if it is possible to turn a into b, and "NO" (without quotes) otherwise.

Examples

Input

01011
0110

Output

YES

Input

0011
1110

Output

NO

Note

In the first sample, the steps are as follows: 01011 → 1011 → 011 → 0110

题目大意:

告诉你两种操作,问你能否将A串变成B串。操作1:删除第一个字符。操作2:在字符串后面添parity(a),这个函数的值为0或1,分别在 串中有偶数个1,奇数个1  时取到。

解题报告:

猜结论的思维题。。。模拟了一下发现真的可以,,。也就是看字符串中最多能造出多少个1来。,因为如果1 的数量大于等于b串中1的数量,,就一定能构造出来、、就是忘了如果1的个数为奇数的时候,,我们可以直接在后面添加一个1变成多一个1,

AC代码:

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<set>
#include<string>
#include<cmath>
#include<cstring>
#define ll long long
#define pb push_back
#define pm make_pair
#define fi first
#define se second
using namespace std;
const int MAX = 2e6 + 5;
int n,k;
char s[MAX],t[MAX];
int main()
{scanf("%s",s+1);scanf("%s",t+1);int cnt1=0,cnt2=0;for(int i = 1; i<=strlen(s+1); i++) {if(s[i] == '1') cnt1++;}for(int i = 1; i<=strlen(t+1); i++) {if(t[i] == '1') cnt2++;}if(cnt1&1) cnt1++;if(cnt1 >= cnt2) puts("YES");else puts("NO");return 0 ;}

【CodeForces - 298C】Parity Game (思维,有坑)相关推荐

  1. Parity Game CodeForces - 298C

    You are fishing with polar bears Alice and Bob. While waiting for the fish to bite, the polar bears ...

  2. CodeForces - 1593G Changing Brackets(思维)

    题目链接:点击查看 题目大意:给出一个长度为 nnn 的括号序列,其中包含了 {(,),[,]}\{(,),[,]\}{(,),[,]} 四种括号,现在可以进行两种操作: 将括号反转,代价为 000, ...

  3. CodeForces - 1567C Carrying Conundrum(思维/状压)

    题目链接:点击查看 题目大意:规定加法中使用隔项进位,问给定的 nnn 有多少种方案可以通过 "隔项进位加法" 得到 题目分析:隔项进位意味着奇偶位置的数字互不影响,所以将奇偶位置 ...

  4. CodeForces - 1535C Unstable String(思维)

    题目链接:点击查看 题目大意:规定一个字符串将问号都替换成 000 或 111 后满足 010101 交替的话,该字符串是合法的,现在给出一个长度为 nnn 的字符串,求合法子串的个数 题目分析:两种 ...

  5. CodeForces - 1353E K-periodic Garland(思维+dp)

    题目链接:点击查看 题目大意:给出 n 个灯泡以及其初始状态(开或关),每次操作可以将任意一个灯泡的状态置反,问最少需要操作多少次,可以使得所有开着的灯泡之间相距 k 个单位 题目分析:因为需要满足所 ...

  6. CodeForces - 1323B Count Subrectangles(思维)

    题目链接:点击查看 题目大意:给出一个数组 a 和数组 b 只由 0 和 1 构成,构造出矩阵 maze[ x ][ y ] = a[ x ] * b[ y ],显然maze矩阵同样只由 0 和 1 ...

  7. CodeForces - 1321B Journey Planning(思维)

    题目链接:点击查看 题目大意:给出一个长度为 n 的数列,规定本题中的上升子序列必须满足两个条件: a[ j ] < a[ i ] a[ i ] - a[ j ] = i - j 问累加和最大的 ...

  8. CodeForces - 1066C Books Queries(思维)

    题目链接:点击查看 题目大意:给出n次操作,每次操作分为以下三种:(假设现在有一个空的队列) L x,在最左端插入x R x,在最右端插入x ? x,查询若想要让x到达最右端或最左端,最少需要移除掉几 ...

  9. CF--思维练习-- CodeForces - 215C - Crosses(思维题)

    ACM思维题训练集合 There is a board with a grid consisting of n rows and m columns, the rows are numbered fr ...

最新文章

  1. linux php mysql安装完整版本_Linux下安装PHP+MySQL+Apache完整版
  2. Windows驱动开发学习笔记(一)—— 环境配置第一个驱动程序
  3. 双拼输入法键位图_谈谈小鹤双拼入门(1)
  4. 【转】hadoop 报 Name node is in safe mode 错
  5. R语言观察日志(part7)--RMarkdwon之代码块
  6. (转)SpringMVC学习(五)——SpringMVC的参数绑定
  7. QTP11 5发布,改名UFT
  8. 深度剖析 C++ 对象池自动回收技术实现
  9. Unity联网插件(PUN)
  10. 企业大数据规划建设方案(PPT)
  11. RouterOS(ROS)软路由端口映射转发回流
  12. 悉尼mit it硕士选课 INFO5990
  13. 互联网众筹系统开发-一站式搭建众筹项目建设
  14. SSE(服务器推送事件)的介绍、问题及解决
  15. OpenCV-检测并提取表格
  16. matlab模拟斜抛运动60,大学物理教学改革论文,关于大学物理教学方法改革-Matlab的妙用相关参考文献资料-免费论文范文...
  17. Ceph _backfill and recovery 之间的不同以及 peering理解
  18. html文字自动调整位置,启步学HTML代码(3)文字显示位置控制的代码
  19. android定时调用gc,Android性能:远程触发GC
  20. 使用Druid监控SQL

热门文章

  1. 数据库-Oracle【Oracle数据库设置默认表空间问题及Oracle,SQL,MySQL的自增变量设置】...
  2. 个人博客网页设计_博客个人网页制作网页设计-1
  3. centos安装无线网卡驱动_CentOS下显卡驱动安装的相关思考
  4. python实战项目前后端分离flask_Flask Vue 构建前后端分离的应用
  5. linux中shell编写数组排序,linux bash shell实现对数组快速排序(升序)
  6. 移动app测试的多样性_做移动APP功能测试,这些因素你得都考虑到~
  7. UE4 多个static mesh合并成一个static mesh
  8. 简单的UTF8编码生成
  9. 中如何计算工龄_在Substrate中如何计算交易权重
  10. js如何获取计算机当前时间,js获取当前系统时间