// Codeforces #180 div2 C Parity Game
//
// 这个问题的意思被摄物体没有解释
//
// 这个主题是如此的狠一点(对我来说,),不多说了这
//
// 解决问题的思路:
//
// 第一个假设a字符串和b字符串相等,说直接YES
// 假设b串全是0,直接YES
// 注意到a串有一个性质,1的个数不会超过本身的加1.
// a有个1的上限设为x,b有个1的个数设为y,则假设x < y
// 那么直接NO。
//
// 如今普通情况下。就是模拟啦,找到a的后缀和b的前缀一样的
// 最长的长度设为buf。之后对buf之后的部分进行扫描,假设
// b[i] == '1' ,则在a串的前suf中找一个1,把它添到后面,
// 这样就能够找到了。最后判一下在a中的j下标是否小于suf就能够了
//
// 注意:假设開始a中1的个数是1的时候那么在第一次找到b[i]是1的
// 时候,不用找1.
//
// 解题:
//
// 这样的字符串的题目,情况相对时有那么一点多,关键是曾经看过前缀和后缀
// 作为状态进行转移的动态规划,所以相对有那么一点感觉。感觉是对了。但
// 经历的时间还是太长了。继续练吧。。。。 #include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define ceil(a,b) (((a)+(b)-1)/(b))
#define endl '\n'
#define gcd __gcd
#define highBit(x) (1ULL<<(63-__builtin_clzll(x)))
#define popCount __builtin_popcountll
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const long double PI = acos(-1.L); template<class T> inline T lcm(const T& a, const T& b) { return a/gcd(a, b)*b; }
template<class T> inline T lowBit(const T& x) { return x&-x; }
template<class T> inline T maximize(T& a, const T& b) { return a=a<b? b:a; }
template<class T> inline T minimize(T& a, const T& b) { return a=a<b? a:b; } const int maxn = 1008;
string a;
int fa[maxn];
string b;
int fb[maxn];
int x,y;
int len1,len2;
int suf;
bool cmp(int u){
for (int i=u;i<u+len2;i++){
if (a[i]!=b[i])
return false;
}
return true;
} void solve(){
string s; suf = -1;
int i;
for (i=len1-1;i>=0;i--){
s = a.substr(i);
if (s==b.substr(0,len1-i)){
suf = i;
break;
}
}
//cout <<
// cout << a << endl;
// cout << b << endl;
//cout << "suf = " << suf << endl;
int flag = 0; //cout << "fb = " << fb[len2-1] << endl;
if (suf == -1)
suf = len1-1;
int x = len1 - suf;
int j = 0;
int even = 0;
//cout << " x " << x << endl;
i = x;
if (fa[len1]&1){
b[i] == '0';
while(!a[j]&&j<suf)
j++;
j++;
}
for (; i < len2; i++) {
if (b[i]=='1'){
while(j<suf){
if (s[j]=='1'){
break;
}
j++;
}
}
}
if (j<suf){
puts("YES");
}else {
puts("NO");
}
} void init(){
memset(fa,0,sizeof(fa));
memset(fb,0,sizeof(fb));
len1 = a.size();
len2 = b.size();
x = 0;
y = 0;
int i;
for (i=0;i<len1;i++){
if (a[i]=='1'){
x++;
fa[i] = x;
}
}
for (i=0;i<len2;i++)
if (b[i]=='1'){
y++;
fb[i] = y;
}
if (( !(x&1) && x < y) || ((x&1) && x+1 < y)){
puts("NO");
return ;
} if (!fb[len2-1]){
puts("YES");
return ;
} solve(); } int main() {
//freopen("G:\\Code\\1.txt","r",stdin);
while(cin >> a >> b){
if (a==b){
puts("YES");
continue;
}
init();
}
return 0;
}

版权声明:本文博主原创文章,博客,未经同意不得转载。

Codeforces #180 div2 C Parity Game的更多相关文章

  1. Codeforces #541 (Div2) - E. String Multiplication(动态规划)

    Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...

  2. Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)

    Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...

  3. Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)

    Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...

  4. Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)

    Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...

  5. 【Codeforces #312 div2 A】Lala Land and Apple Trees

    # [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...

  6. Codeforces #263 div2 解题报告

    比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...

  7. codeforces #round363 div2.C-Vacations (DP)

    题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits ...

  8. codeforces round367 div2.C (DP)

    题目链接:http://codeforces.com/contest/706/problem/C #include<bits/stdc++.h> using namespace std; ...

  9. codeforces 235 div2 C Team

    题目:http://codeforces.com/contest/401/problem/C 题意:n个0,m个1,求没有00或111的情况. 这么简单的题..... 做题的时候脑残了...,今天,贴 ...

随机推荐

  1. CacheManager

    .Net缓存管理框架CacheManager Cache缓存在计算机领域是一个被普遍使用的概念.硬件中CPU有一级缓存,二级缓存, 浏览器中有缓存,软件开发中也有分布式缓存memcache, redi ...

  2. Redis测井系统

    什么是 SLOWLOG Slow log 是 Redis 用来记录查询运行时间的日志系统. 查询运行时间指的是不包含像client响应(talking).发送回复等 IO 操作,而单单是运行一个查询命 ...

  3. Objective-C辛格尔顿

    单例类是一种特殊的类.在一个进程种仅仅会存在一个该类的对象,在iOS应用中仅仅会出现一个对象.这样的设计模式在系统框架中很多地方都使用了.如NSFileManager.UIApplication等. ...

  4. Tomcat通过配置一个虚拟路径管理web工程

    关于虚拟路径.学问javaweb训练课程,如今,鉴于这种情况下老师. 当我们的项目,当在不同的文件夹项目.我们如何使用tomcat去管理web工程. 教师提出的解决方案是 使用虚拟路径方式,并按照实施 ...

  5. TFS:TF30042 数据库已满 处理方法

    原文:TFS:TF30042 数据库已满 处理方法 今天早上,公司打来电话,说TFS(Team Foundation Server)微软源代码管理软件签入不了,报错:TF30042 数据库已满. 经过 ...

  6. HDU - 5186 - zhx&#39;s submissions (精密塔尔苏斯)

    zhx's submissions Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  7. js 性能优化整理之 惰性载入

    跨检查浏览器特性,解决不同浏览器的兼容问题. 例如,我们最常见的为 dom 节点添加事件的函数 function addEvent(element,type,handler){ if(element. ...

  8. 面向对象的软件project——面向对象分析

    为了解决软件危机.一些IT前辈国产软件project这个词汇,软件project它被引入到整个软件开发过程的维护. 软件project从程序的设计角度能够分为两类.一类是面向结构的软件project. ...

  9. Android 获取屏幕大小和密度

    Android 获取屏幕大小和密度 DisplayMetrics metric = new DisplayMetrics(); getWindowManager().getDefaultDisplay ...

  10. SVN目录对号图标(更新、冲突)不显示

    长谈想知道,大约SVN这些冲突.变化.加入.不显示问题etc目录下的复选图标,退房的在线信息,多数说的更改icon的settings,后来,一点点仔细阅读SVN配有英文说明文档,我相信,改变是有点问题 ...