摘要: 牛客多校第三场 D- Points Construction Problem 链接: Points Construction Problem 题意: 在2D平面内,每个格点(整数点)有一个白点,可以将其中一些点涂黑。 问能否将n个白点涂黑,使得有m对相邻的白点和黑点(指哈夫曼距离为1) 解法: (1 阅读全文
posted @ 2020-07-20 16:56 UCPRER 阅读(212) 评论(0) 推荐(0) 编辑
摘要: Operating on a Graph 题意: 给定一个无向图,有n个点,点i初始时属于集合i。给出q个操作,每次操作针对集合oi,将与集合oi相邻的集合全部加入集合oi中(若集合oi已经不存在了就无事发生)。在q个操作结束之后,问每个点属于的集合。 解法: 显然应该用并查集维护每个点属于哪个集合 阅读全文
posted @ 2020-07-20 09:40 UCPRER 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 链接: "2018 2019 ICPC Southwestern European Regional Programming Contest (SWERC 2018)" 题意: 一个无向图,图上有三个关键点A,B,C,统计图上点u的个数,满足没有其他点v到A,B,C的最短距离都比u到A,B,C的最短 阅读全文
posted @ 2020-05-16 17:39 UCPRER 阅读(429) 评论(0) 推荐(0) 编辑
摘要: (1)在Edit File ecoding中,选中以下两项 (2) 在Setting Compiler settings Global compiler settings Other compiler options中, 输入以下两项: finput charset=UTF 8 fexec char 阅读全文
posted @ 2020-05-11 20:56 UCPRER 阅读(2556) 评论(0) 推荐(1) 编辑
摘要: 计算几何基础模板 基础类型 const double eps = 1e-8; const double PI=acos(-1.0); int sgn(double x) { if(fabs(x) < eps) return 0; if(x < 0) return -1; return 1; } st 阅读全文
posted @ 2020-05-11 10:30 UCPRER 阅读(186) 评论(0) 推荐(0) 编辑
摘要: GCD相关 GCD ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); } EXGCD void exgcd(ll a,ll b,ll &x,ll &y){ if(b==0) x=1,y=0; else{ exgcd(b,a%b,y,x),y- 阅读全文
posted @ 2020-05-11 10:26 UCPRER 阅读(211) 评论(0) 推荐(0) 编辑
摘要: ```cpp#include using namespace std;const int maxn = 5e3 + 5;const int maxm = 5e5 + 5;namespace MST { struct edge { int u, v, w; }E[maxm]; int n, m; int tot = 0; void addedge(int u, int v, int w) { E... 阅读全文
posted @ 2020-03-03 23:36 UCPRER 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 在数字电路中,经常会遇到进制转换问题,如二进制 (Binary) 转 BCD (Binary Coded Decimal)。针对这种数制的转换,有个很神奇的算法—— double dabble algorithm ,也称为 shift and add 3 algorithm 。 其主要流程如下(摘自 阅读全文
posted @ 2020-02-20 23:01 UCPRER 阅读(919) 评论(0) 推荐(0) 编辑
摘要: //求LCA,k级祖先 #include <bits/stdc++.h> using namespace std; const int maxn = 5e5+5; const int maxm = 1e6+5; int lg[maxn]; struct edge { int next, v; }E[ 阅读全文
posted @ 2020-02-08 19:46 UCPRER 阅读(146) 评论(0) 推荐(0) 编辑
摘要: ```cpp //静态区间最值 #include using namespace std; const int maxn = 1e5 + 5; int ST[maxn][25]; int a[maxn]; void STinit(int n) { for (int i = 1; i > n >> m; for (int i = 1; i <= n; i++) { scanf("%d", &a[i] 阅读全文
posted @ 2020-02-07 21:35 UCPRER 阅读(134) 评论(0) 推荐(0) 编辑