随笔分类 -  思维--并查集

摘要:传送门 题意:给定一张不保证联通的简单图,问是否存在染色方案,使得每一个连通块为三分图。 分析:不考虑其他约束,只考虑三分图每一个子集内部没有边相连的约束,先染出一张图。做法为首先对于一个连通块,先选定一个起点u,将u染成1,然后将与u直接相连的点,全部染成2,然后选择一个染成2的点为v,然后将所有 阅读全文
posted @ 2019-09-30 00:07 千摆渡Qbd 阅读(468) 评论(0) 推荐(0)
摘要: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 disturbin 阅读全文
posted @ 2019-01-28 19:21 千摆渡Qbd 阅读(234) 评论(0) 推荐(0)
摘要:小Hi的学校总共有N名学生,编号1-N。学校刚刚进行了一场全校的古诗文水平测验。 学校没有公布测验的成绩,所以小Hi只能得到一些小道消息,例如X号同学的分数比Y号同学的分数高S分。 小Hi想知道利用这些消息,能不能判断出某两位同学之间的分数高低? Input 第一行包含三个整数N, M和Q。N表示学 阅读全文
posted @ 2019-01-28 18:18 千摆渡Qbd 阅读(226) 评论(0) 推荐(0)
摘要:A Bug's Life POJ - 2492 Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two dif 阅读全文
posted @ 2019-01-28 18:17 千摆渡Qbd 阅读(185) 评论(0) 推荐(0)
摘要:Play on Words HDU - 1116 Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that door 阅读全文
posted @ 2019-01-28 18:14 千摆渡Qbd 阅读(168) 评论(0) 推荐(0)
摘要:A : Wireless Network POJ - 2236 题意:并查集,可以有查询和修复操作 题解:并查集 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> us 阅读全文
posted @ 2019-01-24 18:04 千摆渡Qbd 阅读(297) 评论(0) 推荐(0)
摘要:These days, you can do all sorts of things online. For example, you can use various websites to make virtual friends. For some people, growing their s 阅读全文
posted @ 2018-08-19 10:28 千摆渡Qbd 阅读(234) 评论(0) 推荐(0)
摘要:Time limit1000 ms Memory limit10000 kB 动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成 阅读全文
posted @ 2018-08-18 22:35 千摆渡Qbd 阅读(143) 评论(0) 推荐(0)
摘要:Time limit5000 ms Memory limit65536 kB There are so many different religions in the world today that it is difficult to keep track of them all. You ar 阅读全文
posted @ 2018-08-18 22:15 千摆渡Qbd 阅读(110) 评论(0) 推荐(0)
摘要:An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unex 阅读全文
posted @ 2018-08-18 21:29 千摆渡Qbd 阅读(167) 评论(0) 推荐(0)