题意: 给你一些点,还有一些边,每个点上都有一个权值,然后有一些询问,分为两种, query a 询问与a直接或者间接想连的点中最大权值的是那个点,输出那个点,如果那个点的权值小于等于a的权值,那么就输出-1,还有另一种操作就是destroy a b意思是删除a b的关系. 思路: 比较基础的并查集题目,看到删边,很容易想到逆向离线处理,先把最终的状态建立出来,然后对于询问逆向处理,正向是删边,那么逆向肯定是加边了,更新最优的话也是比较简单的并查集小变种(也就是平时说的带…
Connections in Galaxy War Time Limit:3000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3261 Appoint description: Description In order to strengthen the defense ability, many stars in galaxy allied together an…
D-City Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 2933 Accepted Submission(s): 1038 Problem Description Luxer is a really bad guy. He destroys everything he met. One day Luxer went to D-…
貌似某大犇说过 正难则反,,, 题目说要对这张图进行删边,然后判断联通块的个数,那么就可以先把所有边都删掉,之后从后往前加边,若加的边两端点不在同一个联通块中, 那么此时联通快个数少一,否则不变 #include <cstdio> #include <cstring> #include <algorithm> + ; + ; int father[maxn]; int x1[maxm], x2[maxm]; int ans[maxm]; int n, m; int ge…
在很多时候,并查集并不是一个完整的解题方法,而是一种思路. 通过以下题目来体会并查集逆向运用的思想. Description Farmer John and his cows are planning to leave town for a long vacation, and so FJ wants to temporarily close down his farm to save money in the meantime.The farm consists of NN barns con…
题目链接:http://codeforces.com/contest/722/problem/C 题意:每次破坏一个数,求每次操作后的最大连续子串和. 思路:并查集逆向操作 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e5 + 10; ll sum[N], ans[N]; int n, a[N], b[N], father[N], r[N]; bool vis[N]; int…
Connections in Galaxy War Time Limit: 3 Seconds Memory Limit: 32768 KB 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3261 Description: In order to strengthen the defense ability, many stars in galaxy allied together and built…
题目链接:https://vjudge.net/problem/ZOJ-3261 In order to strengthen the defense ability, many stars in galaxy allied together and built many bidirectional tunnels to exchange messages. However, when the Galaxy War began, some tunnels were destroyed by th…