题目链接: http://poj.org/problem?id=1733 题意: 输入n表示有一个长度为n的0,1字符串, m表示接下来有m行输入, 接下来的m行输入中x, y, even表示第x到第y个字符中间1的个数为偶数个, x, y, odd表示第x到第y个字符中间1的个数为奇数个, 若m句话中第k+1是第一次与前面的话矛盾, 输出k; 思路: 若x, y之间1的个数为偶数个, 那么1~x 与1~y中1的个数同奇偶性, 反之则异奇偶性, 我们可以将其理解为若输入x, y, even, 即…
Description After having drifted about in a small boat for a couple of days, Akira Crusoe Maeda was finally cast ashore on a foggy island. Though he was exhausted and despaired, he was still fortunate to remember a legend of the foggy island, which h…
题目大意:有一个长度为n的0,1字符串, 给m条信息,每条信息表示第x到第y个字符中间1的个数为偶数个或奇数个, 若这些信息中第k+1是第一次与前面的话矛盾, 输出k; 思路:x, y之间1的个数为偶数个, 那么1~x 与1~y中1的个数奇偶性相同:若x,y间1的个数为奇数个,那么1~x与1~y中1的奇偶性相同.奇偶性相同的加入同一个并查集 eg:数据范围大,先离散化 #include<stdio.h> #include<algorithm> #define N 100006 us…
Description Now and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for example the subsequence from the third to the fifth digit inclusively) a…
POJ1733 Parity game Description Now and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for example the subsequence from the third to the fifth…
POJ1733 Parity game Description Now and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for example the subsequence from the third to the fifth…
Parity Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12853   Accepted: 4957 题目链接:http://poj.org/problem?id=1733 Description: Now and then you play the following game with your friend. Your friend writes down a sequence consisting…
题目链接:http://poj.org/problem?id=1733 Parity game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 3795 Description Now and then you play the following game with your friend. Your friend writes down a sequence consisting of…
Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15776   Accepted: 5964 Description Now and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subse…
题面 Poj 题解 反正只要你判断是否满足区间的奇偶性,假设每一位要么是\(1\)要么是\(0\)好了. 假设有\(S\)的前缀和为\(sum[]\),则有: 若\(S[l...r]\)中有奇数个\(1\),则\(sum[l-1]\)与\(sum[r]\)不同奇偶:反之,则同奇偶 用一个带权并查集维护,设权值数组\(s[i]\)表示区间\([root[i]...i]\)的和的奇偶性. 对于一个区间\([l,r]\),分情况讨论: 如果\(root[l]=root[r]\),直接判断就行了. 否则…