数据分割 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1119 Accepted Submission(s): 268 Problem Description 小w来到百度之星的赛场上,准备开始实现一个程序自动分析系统. 这个程序接受一些形如xi=xj 或 xi≠xj 的相等/不等约束条件作为输入,判定是否可以通过给每个 w 赋…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5458 Problem Description Given an undirected connected graph G with n nodes and m edges, with possibly repeated edges and/or loops. The stability of connectedness between node u and node v is defined by…
链接:https://ac.nowcoder.com/acm/contest/553/I 思路:离线整棵树,用并查集维护下联通的情况,因为值只有60个,用2的x(1<=x<=60)次方表示,树链剖分线段树区间取或维护,取得的值只要数二进制里面有多少个1就代表有多少个相同的数. 实现代码: #include<bits/stdc++.h> using namespace std; #define ll long long #define lson l,m,rt<<1 #de…
F. Palindrome Problem Description A string is palindrome if it can be read the same way in either direction, for example "maram" is palindrome, while "ammar" is not. You are given a string of n characters, where each character is eithe…
题目链接:https://www.nowcoder.com/acm/contest/94/B 题意:在一棵有 n 个节点的树上,有两种操作,一个是把 u 到 v 的路径走一遍,另一个是查询 u 到 fa[ u ]的路径走了几次,如果没走过输出“ Not yet ”,走过一次升序输出经过要走这条路时的路径端点,否则输出“ Many Times”. 题解:因为只需记录每条路径经过一次,若一条路径经过了多次,则访问该节点时可跳到它的没有访问过路径的祖先上面,故可以使用并查集来实现. #include…
FZU 2112 Tickets Time Limit:3000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Practice Description You have won a collection of tickets on luxury cruisers. Each ticket can be used only once, but can be used in either direction betwee…
并查集的经典题型,POJ上题目还是中文= =,一般看到中文题都会感觉不太简单,这道题的数学归纳用得比较多,可以简化代码,挺有意思的. 同类型的题目还有POJ1703,比这个要简单,想了解并查集基本介绍或想参考Code请移步:算法手记 之 数据结构(并查集详解)(POJ1703) 存在食物链: A吃B,B吃C,C吃A 给出两种判断:1 a b 指a和b相同 2 a b 指a吃b 现依照题目输入,输出判断的错误次数:1.a,b超过N错误 2.a,b不符合前面判断则错误 Code仅供参考: //食物链…
Mr. Kitayuta's Colorful GraphTime Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description Mr. Kitayuta has just bought an undirected graph consisting of n vertices and m edges. The vertices of the graph are numbered to n. Each ed…
点击打开链接 D.D-City Description Luxer is a really bad guy. He destroys everything he met. One day Luxer went to D-city. D-city has N D-points and M D-lines. Each D-line connects exactly two D-points. Luxer will destroy all the D-lines. The mayor of D-ci…
度度熊保护村庄 Accepts: 13 Submissions: 488 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description 哗啦啦村袭击了喵哈哈村! 度度熊为了拯救喵哈哈村,带着自己的伙伴去救援喵哈哈村去了!度度熊与伙伴们很快的就过来占据了喵哈哈村的各个军事要地,牢牢的守住了喵哈哈村. 但是度度熊发现,这是一场旷日持久的战斗,所以度度熊决定要以逸…
Ubiquitous Religions Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 23093 Accepted: 11379 Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in findi…