随笔分类 -  ACM---并查集及扩展

摘要:Problem 2155 盟国 Accept: 39Submit: 129Time Limit: 1000 mSecMemory Limit : 32768 KB Problem Description世界上存在着N个国家,简单起见,编号从0~N-1,假如a国和b国是盟国,b国和c国是盟国,那么a国和c国也是盟国。另外每个国家都有权宣布退盟(注意,退盟后还可以再结盟)。定义下面两个操作:“M X Y” :X国和Y国结盟“S X” :X国宣布退盟 Input多组case。每组case输入一个N和M (1 ≤ N ≤ 100000 , 1 ≤ M ≤ 1000000),N是国家数,M是操作数。接下 阅读全文
posted @ 2014-03-24 18:33 芷水 阅读(230) 评论(0) 推荐(0)
摘要:How Many Answers Are WrongTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1475 Accepted Submission(s): 596Problem DescriptionTT and FF are ... friends. Uh... very very good friends -________-bFF is a bad boy, he is always wooing TT to play the fol 阅读全文
posted @ 2013-07-01 08:05 芷水 阅读(308) 评论(0) 推荐(0)
摘要:The SuspectsTime Limit:1000MSMemory Limit:20000KTotal Submissions:17876Accepted:8659DescriptionSevere acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is to separa 阅读全文
posted @ 2013-06-30 09:50 芷水 阅读(208) 评论(0) 推荐(0)
摘要:Wireless NetworkTime Limit:10000MSMemory Limit:65536KTotal Submissions:13679Accepted:5796DescriptionAn earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the n 阅读全文
posted @ 2013-06-28 16:28 芷水 阅读(251) 评论(0) 推荐(0)
摘要:Find them, Catch themTime Limit:1000MSMemory Limit:10000KTotal Submissions:24739Accepted:7435DescriptionThe 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 Dragon and Gang Snake. However, the police first needs to identify whi 阅读全文
posted @ 2013-06-28 15:17 芷水 阅读(230) 评论(0) 推荐(0)
摘要:Parity gameTime Limit:1000MSMemory Limit:65536KTotal Submissions:5287Accepted:2074DescriptionNow 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 阅读全文
posted @ 2013-06-27 14:45 芷水 阅读(226) 评论(0) 推荐(0)
摘要:hdu 1598find the most comfortable road题目的意思是很多连接的点中,问x到y点的最小差值。差值的计算是,在这条路径中的最大的值-最小的值。感觉像流的问题。却十分巧妙的用并查集来做。问题的关键还是在处理 最小差值。1贪心+并查。将排序(从小到大)后的进行判断,是否f[x]==f[y]来结束。那谁是起点??这也是个难点,任一点都可能是起点,我们只能通过for(i=1;i=m+1)break; if(a[j].info-a[i].info<ans) ans=a[j].info-a[i].info; } if(ans==10000003) return -1; 阅读全文
posted @ 2013-06-27 14:42 芷水 阅读(202) 评论(0) 推荐(0)