题目传送 Parity game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10870   Accepted: 4182 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…
地址 连通性判定问题.(具体参考lyd并查集专题该题的转化方法,反正我菜我没想出来).转化后就是一个经典的并查集问题了. 带权:要求两点奇偶性不同,即连边权为1,否则为0,压缩路径时不断异或,可以通过0或1得到两点的关系.合并时解一个位运算的方程,可得一个根连向另一个根的权值,看code,就不细讲了. #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include&…
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…
题目链接:http://poj.org/problem?id=1733 题意:给定由0.1组成的数串长度n,询问次数m,每次询问给出a,b,s,表示区间[a,b]内1的数量为s(odd-奇数或even-偶数),求前几次询问的答案是正确的. 思路:此题类似与poj1182,属于并查集的向量应用.首先n<=1e9,必须要用到离散化,这里用map实现,详见代码.然后要用到带权并查集,用1表示odd,0表示even.用root[i]表示i的祖先r,f[i]表示[r,i)(左闭右开,所以输入的b要加一)之…
题面 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]\),直接判断就行了. 否则…
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 题目描述 你和你的朋友玩一个游戏.你的朋友写下来一连串的0或者1.你选择一个连续的子序列然后问他,这个子序列包含1的个数是奇数还是偶数.你的朋友回答完你的问题,接着你问下一个问题. 你怀疑你朋友的一些答案可能是错误的,你决定写一个程序来帮忙.程序将接受一系列你的问题及你朋友的回答,程序的目的是找到第一个错误的回答i,也就是存在一个序列满足前i-1个问题的答案,但是不满足前i个问题. 输入 第一行有一个整数L(L<=1000000000…
传送门 Find them, Catch them Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 42463   Accepted: 13065 Description The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang D…
题目描述: 经过不懈的努力,Hzwer召唤了很多陨石.已知Hzwer的地图上共有n个区域,且一开始的时候第i个陨石掉在了第i个区域.有电力喷射背包的ndsf很自豪,他认为搬陨石很容易,所以他将一些区域的陨石全搬到了另外一些区域. 在ndsf愉快的搬运过程中,Hzwer想知道一些陨石的信息.对于Hzwer询问的每个陨石i,你必须告诉他,在当前这个时候,i号陨石在所在区域x.x区域共有的陨石数y.以及i号陨石被搬运的次数z. 输入描述: 输入的第一行是一个正整数T.表示有多少组输入数据. 接下来共有…
True Liars Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2713   Accepted: 868 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 exha…