传送门 题意简述:给出一张图问不在从sss到ttt所有简单路径上的点数. 思路: 枚举删去每个点然后把整张图用并查集处理一下,同时不跟sss和ttt在同一个连通块的点就是满足要求的点(被删去的不算). 代码: #include<bits/stdc++.h> #define ri register int using namespace std; inline int read(){ int ans=0; char ch=getchar(); while(!isdigit(ch))ch=getc…
传送门 题意:维护可持久化并查集,支持在某个版本连边,回到某个版本,在某个版本 询问连通性. 思路: 我们用主席树维护并查集fafafa数组,由于要查询历史版本,因此不能够用路径压缩. 可以考虑另外一种优化方式:按秩合并貌似直接瞎合并也能过 于是主席树再额外维护一个该节点的秩即可. 代码: #include<bits/stdc++.h> #define ri register int using namespace std; inline int read(){ int ans=0; char…
题目描述 Farmer John has bought property in the Caribbean and is going to try to raise dairy cows on a big farm composed of islands. Set in his ways, he wants to surround all the islands with fence. Each island in the farm has the shape of a polygon. He…
find the most comfortable road Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4899 Accepted Submission(s): 2131 Problem Description XX星有很多城市,城市之间通过一种奇怪的快速公路SARS(Super Air Roam Structure---超…
题目链接:http://poj.org/problem?id=2912 Rochambeau Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 3663 Accepted: 1285 Description N children are playing Rochambeau (scissors-rock-cloth) game with you. One of them is the judge. The rest ch…
传送门 题意:给一堆五维的点,求最远点对. 思路:跟CF1093G差不多 考虑把正负号状压成一个323232以内的数,然后对于每一类分别求最大最小值再做差更新答案即可. 代码: #include<iostream> #include<cstdio> #define ri register int using namespace std; int n; double mx,mn,p[100005][5]; int main(){ scanf("%d",&n…
传送门 题意简述:给出一个序列,支持把ppp~nnn中所有小于等于apa_pap的'扯出来排序之后再放回去,要求动态维护全局逆序对. 思路:我们令fif_ifi表示第iii个位置之后比它大的数的个数,考虑到一个数在排一次序之后fif_ifi就变成了000,因此等价于每个位置最多修改一次,我们用树状数组先求出fif_ifi,然后上线段树来暴力修改即可. 代码: #include<bits/stdc++.h> #define ri register int using namespace…
传送门 题意简述:给出一张DAGDAGDAG,要求删去不超过kkk条边问最后拓扑序的最大字典序是多少. 思路:贪心帮当前不超过删边上限且权值最大的点删边,用线段树维护一下每个点的入度来支持查询即可. 注意要在选点的时候更新后继的入度 代码: #include<bits/stdc++.h> #define ri register int using namespace std; inline int read(){ int ans=0; char ch=getchar(); while(!isd…
这题单用map过不了,太慢了,所以改用unordered_map,对于前面删除的点,把它的父亲改成,后面一位数的父亲,初始化的时候,map里是零,说明它的父亲就是它本身,最后输出答案的时候,输出每一位数的父亲就好了. 下面的程序可能在windows本地编译过不了,头文件放在下面. #include <bits/stdc++.h> using namespace std; unordered_map<int,int>mp; int find(int x) { if (mp[x]==0…
hdu1598 find the most comfortable road Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3300 Accepted Submission(s): 1406 Problem Description XX星有许多城市,城市之间通过一种奇怪的高速公路SARS(Super Air Roam Struc…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1598 find the most comfortable road Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3783 Accepted Submission(s): 1617 Problem Description XX星有许多…
Our lovely KK has a difficult Social problem. A big earthquake happened in his area. N(2≤N≤2000)N(2≤N≤2000) cities have been implicated. All the roads between them are destroyed. Now KK was commissioned to rebuild these roads. However, after investig…
find the most comfortable road Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3686 Accepted Submission(s): 1565 Problem Description XX星有很多城市,城市之间通过一种奇怪的快速公路SARS(Super Air Roam Structure---超…