In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table and players try to remove them one-by-one without disturbing the other straws. Here, we are only concerned with if various pairs of straws are connected b…
Jack Straws Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5428   Accepted: 2461 Description In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table and players try to remove them one-by-one witho…
原题如下: Jack Straws Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5555   Accepted: 2536 Description In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table and players try to remove them one-by-one…
Jack Straws Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 2911   Accepted: 1322 Description In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table and players try to remove them one-by-one witho…
Jack Straws Description In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table and players try to remove them one-by-one without disturbing the other straws. Here, we are only concerned with if various pairs o…
/** http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1840    题意:    判断线段是否相交  (包括间接相交)    输入:     N(代表有n条线段)     sx  sy  ex  ey(一条直线的两端点的坐标)     :     :     :     a b(判断第a条和第b条线段是否相交)     :     :      :     0 0输入0 0 询问结束     输出…
Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 16065   Accepted: 6778 Description An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computer…
题意:       有n个点,一开始大家都是独立的点,然后给出一些关系,a,b表示a是b的父亲节点,距离是abs(a-b)%1000,然后有一些询问,每次询问一个节点a到父亲节点的距离是多少? 思路:      可以直接简单带权并查集就能搞定,核心代码是这样,设s_x[i]表示i到自己父亲节点的距离,然后 //处理并查集的时候 int finds(int x) {   if(x == mer[x]) return x;   int k = mer[x];   mer[x] = finds(mer…
为什么ACM的题意都这么难懂,就不能说的直白点吗?还能不能好好的一起刷题了? 题意:你需要建一个n的并查集,有m个集合,最后要输出包含0的那个集合的元素的个数. 这是简单并查集应用,所以直接看代码吧! #include <map> #include <set> #include <list> #include <cmath> #include <queue> #include <stack> #include <vector&g…
题意大致为找同性恋的虫子.... 这个比食物链要简单些.思路完全一致,利用取余操作实现关系之间的递推. 个人感觉利用向量,模和投影可能可以实现具有更加复杂关系的并查集. #include<iostream> #include<cstdio> using namespace std; ; int fa[MAXN];int rel[MAXN]; //rel[i]=0 代表与根节点同性,1代表异性 void _set(int a) { ;i<=a;i++) { fa[i]=i; r…