摘要: 题意:给定一个正整数n,和一个1-n的一个排列,每个数可以和旁边的两个数的任意一个交换,每交换一次总次数就要加一,问将这个排列转换成一个递增的排列需要多少次交换? 题意可以转换成求这个排列的逆序对数。 #include<iostream> #include<cstdio> #include<cstr 阅读全文
posted @ 2019-07-13 22:00 starve_to_death 阅读(115) 评论(0) 推荐(0) 编辑
摘要: D. Tokitsukaze, CSL and Stone Game 题意:有n堆石头,每人每次只能去一颗石子,若轮到当前人没任何一堆石子可以取或当前人取到后剩下有俩堆石子个数相同则当前人输; 给定石子序列。 分析:1、若有类似“2 3 3 ”则后手胜,因为有这个序列就必须在这个序列中去石子(因为如 阅读全文
posted @ 2019-07-13 17:26 starve_to_death 阅读(203) 评论(0) 推荐(0) 编辑
摘要: https://www.luogu.org/problemnew/show/P3980 源点连第一天 汇点连最后一天 容量为INF费用为0 这样跑网络流是沿时间流的(就是依次解决每一天的问题) 然后每一天向后一天连一条容量为INF-a[i] 费用为0的边 为什么容量为INF-a[i] 这就相当于少了 阅读全文
posted @ 2019-07-12 19:19 starve_to_death 阅读(147) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3659 #include<iostream> #include<cstring> #include<algorithm> #include<cstdio> #include<vector> using namespace std; const i 阅读全文
posted @ 2019-07-11 09:12 starve_to_death 阅读(168) 评论(0) 推荐(0) 编辑
摘要: http://codeforces.com/contest/1187/problem/E 分析:问得分最高,实际上就是问以哪个节点出发得到的分数最多,而呈现成代码形式就变成了换根,max其得分!!!而要利用之前算过的得分来求。 #include<bits/stdc++.h> using namesp 阅读全文
posted @ 2019-07-10 20:03 starve_to_death 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2019-07-10 16:05 starve_to_death 阅读(293) 评论(0) 推荐(0) 编辑
摘要: https://codeforces.com/contest/1187/problem/D 题意:选取a序列的一段【l,r】将选中的区间按非降排序。问能否经过若干次操作后形成b序列; 分析:b序列的数的总类及各个类的数目一定要与a序列相同; 对b的每个位置的值,找到与之相同的a序列中还没有被用的位置 阅读全文
posted @ 2019-07-09 15:45 starve_to_death 阅读(134) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=3694 给一副图,(可能有环,但联通)然后给定q次询问,每次询问的u,v是要加上去的边,问加上去后,若图的边联通度还是1时,有多少条桥 利用并查集缩点,先用tarjan求出总的桥的数量; 利用tarjan中的dfn来找每次u,v的LCA,u到v路 阅读全文
posted @ 2019-07-09 13:49 starve_to_death 阅读(168) 评论(0) 推荐(0) 编辑
摘要: http://poj.org/problem?id=1679 #include<iostream> #include<vector> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; struct 阅读全文
posted @ 2019-07-07 10:47 starve_to_death 阅读(131) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2019-06-24 09:36 starve_to_death 阅读(6) 评论(0) 推荐(0) 编辑