Codeforces 题面传送门 & 洛谷题面传送门 一道非常神仙的题 %%%%%%%%%%%% 首先看到这样的设问,做题数量多一点的同学不难想到这个题.事实上对于此题而言,题面中那个"Classical and Easy"的问题就是那题的弱化版,具体来说,借鉴那题的思路,我们考虑建立一个虚点 \(V\)​,然后对于所有度为奇数的点 \(x\),我们连一条 \(x\) 与 \(V\) 之间的双向边,然后跑欧拉回路.对于每一条原二分图中的边,假设其左部点为 \(x\),右部点为…
题意:给你m条边,每条边有一个权值,每次询问只保留编号l到r的边,让你把这个图分成两部分 一个方案的耗费是当前符合条件的边的最大权值(符合条件的边指两段点都在一个部分),问你如何分,可以让耗费最小 分析:把当前l到r的边进行排序,从大到小,从大的开始不断加边,判断当前能否形成二分图,如果能形成二分图,继续加边 如果不能形成二分图,那当前边的权值就是最小耗费(是不是很眼熟) 思路很清晰,现在我们要解决的是如何判断可以形成二分图,有两种,一个是2染色当前图(肯定超时) 所以只剩一种方法,带权并查集…
C. The Labyrinth 题目连接: http://www.codeforces.com/contest/616/problem/C Description You are given a rectangular field of n × m cells. Each cell is either empty or impassable (contains an obstacle). Empty cells are marked with '.', impassable cells are…
B. Coach 题目连接: http://www.codeforces.com/contest/300/problem/A Description A programming coach has n students to teach. We know that n is divisible by 3. Let's assume that all students are numbered from 1 to n, inclusive. Before the university progra…
Long time ago, there was a great kingdom and it was being ruled by The Great Arya and Pari The Great. These two had some problems about the numbers they like, so they decided to divide the great kingdom between themselves. The great kingdom consisted…
题意:给你一颗树,树边的权值可能是0或1,问先走0边,再走1边,或者只走1边的路径有多少条? 思路:对于一个点,假设通过0边相连的点一共有x个(包括自己),通过1边相连的有y个(包括自己),那么对答案的贡献为x * y - 1,意思是以x个点为起点,以y个点为终点了路径条数,-1是因为自己到自己的不算路径,用带权并查集去统计x和y即可. 代码: #include <bits/stdc++.h> #define LL long long #define db double #define INF…
C. Destroying Array 题目连接: http://codeforces.com/contest/722/problem/C Description You are given an array consisting of n non-negative integers a1, a2, ..., an. You are going to destroy integers in the array one by one. Thus, you are given the permuta…
F. Palindrome Problem Description A string is palindrome if it can be read the same way in either direction, for example "maram" is palindrome, while "ammar" is not. You are given a string of n characters, where each character is eithe…
http://codeforces.com/contest/776/problem/D 注意到每扇门都有两个东西和它连接着,那么,如果第i扇门的状态是1,也就是已经打开了,那么连接它的两个按钮的状态应该是一样的,也就是必须是同时按,或者同时不按.然后0的话就是关闭的,所以连接它的两个按钮应该是一个按,一个不按,或者相反. 所以这就是一个带权并查集(一开始没想到,以为相同的,用并查集合并就好,然后不同的,建立一个图什么的,发现有点麻烦,然后推着推着,就是带权并查集了),然后就写了很久很久,一直wa…
传送门 Find them, Catch them Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 42463   Accepted: 13065 Description The police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang D…