P1 : Jin Yong’s Wukong Ranking List Time Limit:1000ms Case Time Limit:1000ms Memory Limit:512MB Description Jin Yong was the most famous and popular Chinese wuxia (The one who fight bad people by his Wukong i.e. Wushu and Kongfu) novelist who lived i…
题意与分析 2018ICPC北京站A题. 题意是这样的,给定若干人的武力值大小(A B的意思是A比B厉害),问到第几行会出现矛盾. 这题不能出现思维定势,看到矛盾就是矛盾并查集--A>B.A>C是不能推出B>C或者B<C的.相反,大于小于是一种偏序关系,是可以建立有向图的.那么,如果这个有向图中出现了环,就是矛盾的. 问题于是转化为有向图判环问题,这里简单说一下有向图和无向图的判环方法. a) 无向图 删除所有度<=1的顶点及相关的边,并将另外与这些边相关的其它顶点的度减一.…
我发现大佬好像都是用拓扑排序写的(本菜鸡不会拓扑哭唧唧 说一下并查集的做法吧... 就是找两人右边的(辣鸡的那个人)那个是否比左边厉害,厉害的话就矛盾. 如果他俩没比较过就把厉害的并到辣鸡的. (辣鸡的是厉害的上一级 1 #include<stdio.h> 2 #include<algorithm> 3 #include<string.h> 4 #include<map> 5 #include<iostream> 6 #include<st…
题意:有一个技能学习表,是一个DAG,要想正常学习到技能x,要将指向x的技能全部先学到,然后会有一个正常花费cx.然后你还有一种方案,通过氪金dx直接获得技能x.你还可以通过一定的代价,切断一条边.问你学得指定的技能N的最小代价. 源点向每个点连接代价为cx的边,每个点拆点,内部连接代价为dx的边,然后N向汇点连接代价为无穷的边,然后每条原图中的边的容量为切断其的代价. 容易发现,每一个割集的方案恰好对应一种学习到N的所需代价的方案.所以直接跑最小割即可. #include<cstdio> #…
题意:给你两个只由1~6组成的串,问你B串至少要经过几次操作变成A串. 一次操作要么选择一个种类的数,将其全部变成另一种类:要么选择一个数,将其变为另一个数. 可以证明,一定先进行一定数量的第一种操作,然后再进行一定数量的第二种操作. 所以可以BFS预处理序列每种数要变成哪种数所需要的代价.初始状态是123456,代表1->1,2->2,...,6->6,一共才6^6种状态. 然后再枚举一遍所有状态,把该种状态下,剩下的仍然不符的数强行变过去就行了,然后在所有答案中取个最小的. #inc…
P2 : Heshen's Account Book Time Limit:1000ms Case Time Limit:1000ms Memory Limit:512MB Description Heshen was an official of the Qing dynasty. He made a fortune which could be comparable to a whole country's wealth by corruption. So he was known as t…
#1389 : Sewage Treatment 时间限制:2000ms 单点时限:2000ms 内存限制:256MB 描述 After years of suffering, people could not tolerate the pollution in the city any more, and started a long-lasting protest. Eventually, the municipal government made up its mind to deal w…
#1391 : Countries 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are two antagonistic countries, country A and country B. They are in a war, and keep launching missiles towards each other. It is known that country A will launch N missiles. The i-th miss…
#1392 : War Chess 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Rainbow loves to play kinds of War Chess games. There are many famous War Chess games such as "Biography of Cao Cao", "Anecdotes of Wagang Mountain", etc. In this problem, let's c…
#1582 : Territorial Dispute 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 In 2333, the C++ Empire and the Java Republic become the most powerful country in the world. They compete with each other in the colonizing the Mars. There are n colonies on the Mars,…