随笔分类 - 

摘要:发现奇环不可行,偶环可行,考虑二分图。然后染色,方向全都从一种指向另一种就可以了,随意。 阅读全文
posted @ 2019-04-02 19:22 AlphaWA 阅读(239) 评论(0) 推荐(0)
摘要:题目传送门 性质是:把节点dfs序以后,异象石按这个序号排序,然后相邻两两求树上距离,这些距离的和除以二就是最小斯坦纳树。 插入删除的具体操作是根据我们上述性质,用一个set维护dfn,比如插入x,则ans加上:(set里的,即之前已经插进来的)左x + x右 - 左右。 阅读全文
posted @ 2019-04-02 00:40 AlphaWA 阅读(273) 评论(0) 推荐(0)
摘要:会卡vector。 阅读全文
posted @ 2019-03-31 20:46 AlphaWA 阅读(227) 评论(0) 推荐(0)
摘要:1 const int maxn = 4e4 + 5; 2 int T, n, m; 3 int f[maxn], vis[maxn], dis[maxn], ans[maxn]; 4 vector vc[maxn]; 5 vector query[maxn], id[maxn]; 6 7 inline int getf(int v) { return v == f[v] ? v... 阅读全文
posted @ 2019-03-31 20:45 AlphaWA 阅读(268) 评论(0) 推荐(0)
摘要:最小生成树会多样的情况是:两个或多个边等长且连通同样的两个并查集块。 所以可以跑一遍克鲁斯卡尔,每次把当前等长的边数出来,注意不要边找边并查,因为有一部分边是正常跑生成树我们也不会要他的,这种直接跳了;还有一些,是因为你选择了第一个边,然后并在一起了,这时扫到后面的边时他自然会被抛弃。而这种比较委屈 阅读全文
posted @ 2019-03-29 13:20 AlphaWA 阅读(286) 评论(0) 推荐(0)
摘要:题目本质:形成一个拓扑图,不应带自环。 解决方法: 1.先把等于号的部分用dsu缩点; 2.大于和小于号建立拓扑关系; 3.n*m的矩阵,只要用标号n+j代表m集合的第j个就从二维降到一维了; 4.dfs查有没有环:used == 2的那种环是合法的! 5.按照order记录的拓扑顺序自底向上dp一 阅读全文
posted @ 2019-02-25 22:03 AlphaWA 阅读(177) 评论(0) 推荐(0)
摘要:Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no ot 阅读全文
posted @ 2018-08-05 09:34 AlphaWA 阅读(378) 评论(0) 推荐(0)
摘要:John has n tasks to do. Unfortunately, the tasks are not independent and the execution of one task is only possible if other tasks have already been e 阅读全文
posted @ 2018-07-28 22:48 AlphaWA 阅读(277) 评论(0) 推荐(0)
摘要:Recently, Shua Shua had a big quarrel with his GF. He is so upset that he decides to take a trip to some other city to avoid meeting her. He will trav 阅读全文
posted @ 2018-05-31 22:50 AlphaWA 阅读(390) 评论(0) 推荐(0)