CF796C Bank Hacking 题解】的更多相关文章

洛谷链接 题目 Although Inzane successfully found his beloved bone, Zane, his owner, has yet to return. To search for Zane, he would need a lot of money, of which he sadly has none. To deal with the problem, he has decided to hack the banks. There are n ban…
Although Inzane successfully found his beloved bone, Zane, his owner, has yet to return. To search for Zane, he would need a lot of money, of which he sadly has none. To deal with the problem, he has decided to hack the banks. There are n banks, numb…
思路十分简单,答案只有 3 种可能,但是有一些细节需要额外注意一下. code: #include <bits/stdc++.h> #define N 300002 #define setIO(s) freopen(s".in","r",stdin) using namespace std; int val[N],hd[N],to[N<<1],nex[N<<1],d1[N],d2[N],n,edges,maxx,mx,m2,cnt…
题目: 题意: 有一颗树,你可以断开点(第一个随便断,以后只能是和已经断开的点相临的点),每个点有权值,断开之后,经一条边和两条边可以到达的节点权值加一,问到最后出现过的最大的权值. 分析: 为啥断开之后就剩下的点就不算相邻了呢...(原题说的是掉线,可是掉线之后线依然在啊...),其实题意好像是掉线之后就断开了. 拿这不就简单了,不管从谁开始断,都会分成几个子树,然后子树又只能从根开始断,这样就有,选作根的点权值为原权值,剩下的和它相邻的权值+1,剩下的权值+2. 然后就随便处理一下就好了,为…
Codeforce 796 C. Bank Hacking 解析(思維) 今天我們來看看CF796C 題目連結 題目 略,請直接看原題. 前言 @copyright petjelinux 版權所有 觀看更多正版原始文章請至petjelinux的blog 想法 首先稍微在腦中模擬一下大概整個流程是怎麼進行的,會發現以下幾件事: 選取點\(v\)開始整個流程,之後是對以\(v\)為根的樹"Hack",並且銀行防禦力增加只會加到子節點 每個點最多被\(+2\) 那麼我們可以想到以下的結論:…
Code Forces 796C Bank Hacking 题目大意 给一棵树,有\(n\)个点,\(n-1\)条边,现在让你决策出一个点作为起点,去掉这个点,然后这个点连接的所有点权值+=1,然后再将这些刚刚加过一的点的相邻的点的权值+=1 也就是说,除了与根节点相邻的点+=1,其余点+=2 然后求最大集合的最小点权 solution 一看是要求最大的的最小值,首先想到的就是二分,显然想到这个目前没有什么卵用,二分是用来卡最佳答案的,所以使用二分的前提是要给它一个范围去选择,那么现在的任务就是…
题目 Although Inzane successfully found his beloved bone, Zane, his owner, has yet to return. To search for Zane, he would need a lot of money, of which he sadly has none. To deal with the problem, he has decided to hack the banks. There are n banks, n…
思路:共有n-1条边连接n个点,即形成一棵树.一开始需要选择一个点hack--将这个点视为根结点,与它相邻的点防御值加1,与它相隔一个在线点的点的防御也加1.当根节点被hack,即这个点被删除,又变成多棵树.此时,Inzane只有一种选择,因为题目规定"Bank x is neighboring to some offline bank.",即选完第一个点,接下来他只能选择剩下的数的根结点,每个节点的防御值都变得有规律可循--假设把根结点看做第一层,那么第二层的防御值都会加一,其它层都…
题目链接:http://codeforces.com/problemset/problem/796/C 题目大意:有n家银行,第一次可以攻击任意一家银行(能量低于自身),跟被攻击银行相邻或者间接相邻(距离<=2)的银行能量+1,除了第一次外,攻击一家银行需要满足以下条件: ①:跟被攻击过后的银行相邻: ②:能量低于攻击者 ③:银行没有被攻击过 题解:可以从题意得知,比如攻击银行i,如果说银行i能量为t,跟银行距离>=2的银行中能量最大的为mx,自身至少所需能量=max(t+1,mx+2),因为…
http://codeforces.com/contest/796/problem/C Although Inzane successfully found his beloved bone, Zane, his owner, has yet to return. To search for Zane, he would need a lot of money, of which he sadly has none. To deal with the problem, he has decide…