07 2019 档案
摘要:https://www.cnblogs.com/mountaink/p/9878918.html 分析:每次的选取必须选最优的一条链,那我们考虑一下选择这条链后,把这条路上的点的权值更新掉,再采取选最优的一条链的策略,如此往复。 所以考虑利用dfs序来处理线段树,线段树维护的是最最优链的值,已经这条
阅读全文
摘要:A题 线段树可卡时限过 (1500MS) #include<bits/stdc++.h> using namespace std; typedef long long ll; const int inf=0x3f3f3f3f; const int M=1e5+5; int a[M],b[M],mpa
阅读全文
摘要:http://codevs.cn/problem/2370/ #include<bits/stdc++.h> using namespace std; const int M=5e4+5; const int N=20; struct node{ int v,w; node(int vv=0,int
阅读全文
摘要:http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1005&cid=867 #include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #inc
阅读全文
摘要:洛谷2661 https://www.luogu.org/problemnew/show/P2661 分析:求缩点后成环中,环大小最小的size #include<bits/stdc++.h> using namespace std; const int M=2e5+5; vector<int>e[
阅读全文
摘要:学习:https://www.cnblogs.com/lcf-2000/p/5866170.html 题目:http://codevs.cn/problem/1082/ #include<iostream> #include<cstring> #include<cstdio> #include<al
阅读全文
摘要:hdu2642 http://acm.hdu.edu.cn/showproblem.php?pid=2642 题目大意: 现在假设天空是一个二维平面(1000*1000)。坐标从(0,0)点开始。现在给出N条信息。 "B X Y",B为字符,x、y是整数,表示将坐标(x,y)的星星变亮。 "D XY
阅读全文
摘要:题意:给定一个正整数n,和一个1-n的一个排列,每个数可以和旁边的两个数的任意一个交换,每交换一次总次数就要加一,问将这个排列转换成一个递增的排列需要多少次交换? 题意可以转换成求这个排列的逆序对数。 #include<iostream> #include<cstdio> #include<cstr
阅读全文
摘要:D. Tokitsukaze, CSL and Stone Game 题意:有n堆石头,每人每次只能去一颗石子,若轮到当前人没任何一堆石子可以取或当前人取到后剩下有俩堆石子个数相同则当前人输; 给定石子序列。 分析:1、若有类似“2 3 3 ”则后手胜,因为有这个序列就必须在这个序列中去石子(因为如
阅读全文
摘要:https://www.luogu.org/problemnew/show/P3980 源点连第一天 汇点连最后一天 容量为INF费用为0 这样跑网络流是沿时间流的(就是依次解决每一天的问题) 然后每一天向后一天连一条容量为INF-a[i] 费用为0的边 为什么容量为INF-a[i] 这就相当于少了
阅读全文
摘要:http://poj.org/problem?id=3659 #include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #include<vector> using namespace std; const i
阅读全文
摘要:http://codeforces.com/contest/1187/problem/E 分析:问得分最高,实际上就是问以哪个节点出发得到的分数最多,而呈现成代码形式就变成了换根,max其得分!!!而要利用之前算过的得分来求。 #include<bits/stdc++.h> using namesp
阅读全文
摘要:Input The first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of data sets that follow. Each data set should be proce
阅读全文
摘要:https://codeforces.com/contest/1187/problem/D 题意:选取a序列的一段【l,r】将选中的区间按非降排序。问能否经过若干次操作后形成b序列; 分析:b序列的数的总类及各个类的数目一定要与a序列相同; 对b的每个位置的值,找到与之相同的a序列中还没有被用的位置
阅读全文
摘要:http://poj.org/problem?id=3694 给一副图,(可能有环,但联通)然后给定q次询问,每次询问的u,v是要加上去的边,问加上去后,若图的边联通度还是1时,有多少条桥 利用并查集缩点,先用tarjan求出总的桥的数量; 利用tarjan中的dfn来找每次u,v的LCA,u到v路
阅读全文
摘要:http://poj.org/problem?id=1679 #include<iostream> #include<vector> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; struct
阅读全文