TT and FF are ... friends. Uh... very very good friends -________-b  FF is a bad boy, he is always wooing TT to play the following game with him. This is a very humdrum game. To begin with, TT should write down a sequence of integers-_-!!(bored).  Th…
How Many Answers Are Wrong Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6349    Accepted Submission(s): 2395 Problem Description TT and FF are ... friends. Uh... very very good friends -_____…
Description TT and FF are ... friends. Uh... very very good friends -________-b FF is a bad boy, he is always wooing TT to play the following game with him. This is a very humdrum game. To begin with, TT should write down a sequence of integers-_-!!(…
题目链接 食物链类似的题,主要是在于转化,a-b的和为s,转换为b比a-1大s.然后并查集存 此节点到根的差. 假如x的根为a,y的根为b: b - y = rank[y] a - x = rank[x] y - x = s 可以推出b - a = rank[y] - rank[x] + s; 并查集 延迟更新什么的,都忘了啊. 还有这题,如果是x--的话,记得更新0的根. #include <cstring> #include <cstdio> #include <stri…
题意: N和M.有N个数. M个回答:ai, bi, si.代表:sum(ai...bi)=si.如果这个回答和之前的冲突,则这个回答是假的. 问:M个回答中有几个是错误的. 思路: 如果知道sum(ai...bi)=si.假设下一个是sum(ai,ci)=sj.则sum(ai,ci)肯定也知道了.这很符合并查集的结构. *:画个图. 代码: int n,m; int fa[200005]; int sum[200005]; int findFa(int x){ if(fa[x]==x){ re…
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; int n, m; ; int fa[maxn]; int sum[maxn]; int Find(int x){ if (x == fa[x]) return x; else{ int t = fa[x]; fa[x] = Find(fa[x]); sum[x] += sum[t]; return fa[x];…
传送门 和某题类似,只不过奇偶换成了和. ——代码 #include <cstdio> #include <iostream> #define N 1000001 int n, m, ans; int f[N], d[N]; inline int read() { , f = ; char ch = getchar(); ; ) + (x << ) + ch - '; return x * f; } inline int find(int x) { if(x ^ f[x…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3038 题意:数组第 a 个元素到第 b 个元素之间的和为sum: 求有几句话是假的,如果与前面的话有冲突就为假: r[i]代表i的父节点到i的和: #include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> #include<math.h> #define N…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3038 题意:就是给出n个数和依次m个问题,每个问题都是一个区间的和,然后问你这些问题中有几个有问题,有问题的直接忽略. 每个问题给出a-b之间的和为s,其实就是val(b)-val(a-1)的值为s,这样就容易想到用向量的方法来求解 #include <iostream> #include <cstring> #include <cmath> #include <cs…
转自:http://blog.csdn.net/shahdza/article/details/7779230 [HDU]1213 How Many Tables 基础并查集★1272 小希的迷宫 基础并查集★1325&&poj1308 Is It A Tree? 基础并查集★1856 More is better 基础并查集★1102 Constructing Roads 基础最小生成树★1232 畅通工程 基础并查集★2120 Ice_cream's world I 基础并查集★212…