Codeforces Round #408 (Div. 2) A】的更多相关文章

A. Buying A House time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Zane the wizard had never loved anyone before, until he fell in love with a girl, whose name remains unknown to us. The gi…
题目链接: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…
A. Buying A House time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Zane the wizard had never loved anyone before, until he fell in love with a girl, whose name remains unknown to us. The gi…
地址:http://codeforces.com/contest/796/problem/D 题目: D. Police Stations time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Inzane finally found Zane with a lot of money to spare, so they togeth…
Description Zane the wizard is going to perform a magic show shuffling the cups. There are n cups, numbered from 1 to n, placed along the x-axis on a table that has m holes on it. More precisely, cup i is on the table at the position x = i. The probl…
C. Bank Hacking 题目大意:给出一棵n个节点的树,每个节点有一个权值,删掉一个点的代价为当前这个点的权值,并且会使其相邻点和距离为2且中间隔着未被删除的点的点权值加1,现在选一个点开始删,之后每次能删掉被删过的点的相邻点,问删掉整棵树,删各节点花费的最大值最小是多少.(n<=300,000) 思路:确定第一个删的点之后,与这个点相邻的点的删除花费是原权值加1,其他点是原权值加2,把所有点权加2后枚举一个点减2再把相邻的减1,线段树统计答案后改回去,总复杂度O(nlogn),O(n)…
A - Buying A House 题意:给你n个房间,妹子住在第m个房间,你有k块钱,你想买一个离妹子最近的房间.其中相邻的房间之间距离为10,a[i]=0表示已经被别人买了. 题解:扫一遍更新答案即可. #include<bits/stdc++.h> using namespace std; const int maxn = 105; int mp[maxn]; int n,m,k; int main(){ scanf("%d%d%d",&n,&m,&…
传送门 题意 n个点有n-1条边相连,其中有k个特殊点,要求: 删去尽可能多的边使得剩余的点距特殊点的距离不超过d 输出删去的边数和index 分析 比赛的时候想不清楚,看了别人的题解 一道将1个联通块转化为k个树的题目,考虑上界,应该是k-1条边,这k-1条边是原图中连接树与树的边,那么我们操作如下: 1.将特殊点i染色为i,放入队列 2.做一次bfs,对每个点相邻的点染色并判断 3.遍历边,如果边的两点不同色,则输出边的index trick 代码 #include <cstdio> #i…
传送门 题意 给出n个银行,银行之间总共有n-1条边,定义i与j有边相连为neighboring,i到j,j到k有边,则定义i到k的关系为semi- neighboring, 每家银行hack的难度为a[i], 如果hack了一家银行,会使与它关系为neighboring.semi- neighboring的银行难度+1,每次hack的银行满足三个条件: 1.未被hack过 2.与hack的银行相邻,即为neighboring的关系 3.被hack的银行难度不大于 Inzane电脑的hack力(…