题意: 对于n个数a[0]~a[n-1],但你不知道它们的值,通过逐步提供给你的信息,你的任务是根据这些信息回答问题: I P V :告诉你a[P] = V I P Q V:告诉你a[P] XOR a[Q] = V Q K P1..PK:询问a[P1]^a[P2]^...a[PK]的值 n<=20000 题解: 首先看前两个操作: 第一个操作我们可以新加一个节点a[n]=0,则a[p]=val转化为a[p]^a[n]=val. 那么所有知道值的点必定都与a[n]在同一个并查集之内. 我们
题意: 可以这样理解,有n快方形积木,一开始都是单独的放到哪,然后有两种操作 1 M a b 把a所在的那一堆落到b所在那一堆的上面(一开始自己是一堆) 2 C a 问a下面有多少个积木 思路: 感觉很久以前杭电上见过这个题目,比较简单的带权并查集,我们可以维护两个权来满足要求,第一个就是记录集合元素个数,就是合并的时候更新a所在的祖宗节点的距离权值,第二个权值就是距离权值,记录每个元素距离根节点的距离,然后更新就是简单更新没啥说的,还有就是简简单单敲完提交后WA了
B. Coach 题目连接: http://www.codeforces.com/contest/300/problem/A Description A programming coach has n students to teach. We know that n is divisible by 3. Let's assume that all students are numbered from 1 to n, inclusive. Before the university progra
Travel Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5441 Description Jack likes to travel around the world, but he doesn’t like to wait. Now, he is traveling in the Undirected Kingdom. There are n cities and m
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Back to Underworld Time Limit:4000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Description The Vampires and Lykans are fighting each other to death. The war has become so fierc