基本思想: 无; 关键点: 无; #include<iostream> #include<string> #include<vector> #include<algorithm> #include<set> using namespace std; const int maxn = 1000000; ...
分类:
其他好文 时间:
2020-03-14 01:12:51
阅读次数:
56
有一类并查集题目中,起始是一张连了所有边的图。 给出一些操作,让一些边"断裂",再抛出一些问题。 这个时候,就可以考虑逆向合并边。 例题星球大战:https://www.luogu.com.cn/problem/P1197 思路: 因为每次轰炸星球,相当于把一个点完全抹除,相应的边也没了。 那么我们 ...
分类:
其他好文 时间:
2020-03-12 14:24:15
阅读次数:
54
A 略 B 略 C 有解当且仅当存在 $a_i + a_j \geq L$ D $\triangle$ 考虑一个暴力:整体二分,每次遍历整张图 由于每次访问的点的数量跟二分的mid有关,直接t飞 可以发现上面这个算法并没有很好地重复利用之前的信息 考虑把信息用并查集维护,然后把 $1 \sim m$ ...
分类:
其他好文 时间:
2020-03-12 09:54:36
阅读次数:
92
有一个划分为N列的星际战场,各列依次编号为1,2,…,N。 有N艘战舰,也依次编号为1,2,…,N,其中第i号战舰处于第i列。 有T条指令,每条指令格式为以下两种之一: 1、M i j,表示让第i号战舰所在列的全部战舰保持原有顺序,接在第j号战舰所在列的尾部。 2、C i j,表示询问第i号战舰与第 ...
分类:
其他好文 时间:
2020-03-11 15:34:35
阅读次数:
51
//AC#include <iostream> #include <string> #include <cstring> using namespace std; int find(int k, int r[]) { int root = k; while (root != r[root]) { r ...
分类:
其他好文 时间:
2020-03-10 22:13:29
阅读次数:
63
"Link" 实际上我们是维护了两个森林。 合并两个点时,我们考虑新建一个点,用这个新建的点储存信息,然后把需要合并的两个点所在树的根连到这个点上。 如果仅有大学的操作,我们可以每次给修改的树的根打一个,那么询问的就是一个点到树根的路径上的权值和,这个可以用带权并查集实现。 现在加上了军队的操作,如 ...
分类:
其他好文 时间:
2020-03-09 21:12:43
阅读次数:
51
基本思想: 无; 关键点: 无; #include<iostream> #include<string> #include<vector> #include<map> using namespace std; const int maxn = 1020; int father[maxn]; int ...
分类:
其他好文 时间:
2020-03-06 01:25:41
阅读次数:
77
https://www.luogu.com.cn/problem/P1546 #include<bits/stdc++.h> #define N 1000 using namespace std; struct node{ int x,y,w; bool const < (node &o){ ret ...
分类:
其他好文 时间:
2020-03-05 00:49:04
阅读次数:
69
Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are ...
分类:
其他好文 时间:
2020-03-04 15:07:02
阅读次数:
86
A. Wormhole Sort https://codeforces.com/group/5yyKg9gx7m/contest/270203/problem/A 分析: 首先可以想到二分w。判断其中一个数x是否符合要求,考虑并查集。把大于x的w放在一个集合。看这个集合中,所有错位母牛的编号和他的位 ...
分类:
其他好文 时间:
2020-03-03 22:44:36
阅读次数:
71