Parity Game CodeForces - 298C

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 a into 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

唉,那个奇偶的地方真的让人烦死了。直接上代码

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;

const int maxx=1e3+10;
char s1[maxx];
char s2[maxx];

int main()
{
	while(cin>>s1>>s2)
	{
		int len1=strlen(s1);
		int len2=strlen(s2);
		int sum1=0;
		int sum2=0;
		for(int i=0;i<len1;i++) if(s1[i]=='1') sum1++;
		for(int i=0;i<len2;i++) if(s2[i]=='1') sum2++;
		if(sum1%2) sum1+=1;
		if(sum1>=sum2) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
 } 

努力加油a啊,(o)/~

can achieve near-Shannon limit performance. Can you explain how protograph-based LDPC codes work and what makes them effective in achieving high accuracy? Sure, I'd be happy to explain. LDPC codes are a type of error-correcting code used in digital communication systems to mitigate the effects of noise and interference. Protograph-based LDPC codes are a type of LDPC code that use a protograph matrix to describe the code structure. The protograph matrix specifies the connectivity pattern of the code's check matrix, which is used to detect and correct errors in the transmitted data. The use of protographs allows for the creation of highly structured LDPC codes with a well-defined pattern of connections between nodes. This structure makes it easier to design and analyze the codes, which leads to better performance. Additionally, protograph-based LDPC codes can be optimized for specific transmission scenarios, further improving their performance. The near-Shannon limit performance of protograph-based LDPC codes can be attributed to their ability to correct a high percentage of errors with a low probability of error. This is achieved through the iterative decoding process, where the received data is repeatedly processed through the protograph-based LDPC code until the probability of error is minimized. By carefully constructing the protograph matrix and optimizing the decoding algorithm, protograph-based LDPC codes can achieve extremely high accuracy in noisy communication channels.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

starlet_kiss

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值