随笔分类 -  数据结构#并查集

摘要:// Problem: CF1278D Segment Tree // Contest: Luogu // URL: https://www.luogu.com.cn/problem/CF1278D // Memory Limit: 250 MB // Time Limit: 2000 ms // 阅读全文
posted @ 2021-08-03 21:07 OvO1 阅读(65) 评论(0) 推荐(0)
摘要:问题 D: Values 时间限制: 1 Sec 内存限制: 128 MB 题目描述 Given is a simple undirected graph with N vertices and M edges. The i-th edge connects Vertex ci and Vertex 阅读全文
posted @ 2021-07-27 19:39 OvO1 阅读(60) 评论(0) 推荐(0)
摘要:题目链接 #思路: 将相交或相切的用并查集维护起来,最后看上表面跟下表面能否在同一个连通块。 #代码: #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> #in 阅读全文
posted @ 2021-06-08 22:08 OvO1 阅读(127) 评论(0) 推荐(0)
摘要:#2021年河南省赛——I.七便士(思维+并查集) 原题链接 #思路: 可以看出,如果未填充的部分是一条链的话,可以把剩下的都添进去。比如,第一次填倒数第二个,然后移动到倒数第一个,以此类推。 用并查集判的。 #代码: #define PI acos(-1) const int maxn=1e5+1 阅读全文
posted @ 2021-05-30 17:50 OvO1 阅读(271) 评论(0) 推荐(0)
摘要:传送门 #A Paint the Numbers ##思路: 排序后从小到大枚举,每次都将当前数的倍数并且未染色的数跟该数染同一种颜色。 ##代码: int n,a[maxn],res; int vis[maxn]; int main(){ cin>>n; for(int i=1;i<=n;i++) 阅读全文
posted @ 2021-05-11 14:10 OvO1 阅读(92) 评论(0) 推荐(0)
摘要:CF776D The Door Problem 原题链接 题意: 给定 n扇门 m 把钥匙,每一把钥匙会同时控制 k_i 扇门,每扇门最多被两把钥匙控制。求是否存在一个使用钥匙的方法使得全部的门都变成开的。 思路1(2-sat): 与上题类似,考虑每扇门的不同初始状态造成的不同操作。 若该门初始状态 阅读全文
posted @ 2021-05-02 14:58 OvO1 阅读(109) 评论(0) 推荐(0)