地址: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…
Inzane finally found Zane with a lot of money to spare, so they together decided to establish a country of their own. Ruling a country is not an easy job. Thieves and terrorists are always ready to ruin the country's peace. To fight back, Zane and In…
D. Vladik and Favorite Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output This is an interactive problem. Vladik has favorite game, in which he plays all his free time. Game field could…
题目链接:https://vjudge.net/contest/226823#problem/C You play a computer game. Your character stands on some level of a multilevel ice cave. In order to move on forward, you need to descend one level lower and the only way to do this is to fall through t…
https://codeforc.es/contest/1176/problem/E 久了不写bfs了.一开始用dfs写,的确用dfs是很有问题的,一些奇怪的情况就会导致多染一些色. 注意无向图的边要开双倍. #include<bits/stdc++.h> using namespace std; typedef long long ll; int n, m; struct Edge { int u, v; int next; Edge() {} Edge(int u, int v, int…
题意:给定 n 个数,有正数和-1, -1表示罪犯,正数表示招了几个警察,一个警察只能看一个罪犯,并且要按顺序,问你有多少罪犯逃脱. 析:很简单么,从开始扫到最后,把是正数就加上,是-1判断剩余警察大于0,如果是就让警察数减1,如果不是答案加1. 代码如下: #include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 1e5 + 5; const int INF = 0x3f3f3f3…
找中间的数,然后从两头取. #include<stdio.h> ; int pos[MAX]; int main() { int n,m,tmp; int i; int pol; long long ans,dis; while(scanf("%d %d",&n,&m)!=EOF) { ;i<=n;i++) scanf("%d",&pos[i]); pol=n/+; tmp=m; ans=; ;i<=pol;) { d…
决定在 codeforces 练题啦,决定每个比赛刷前四道...太难就算了 796A Buying A House 题意:给出x轴上的n 个点,每个点有个权值,问离m 点最近的权值小于等于k 的点离m的距离.单位是10. 思路:大水题.用l.r分别向左向右找即可. 代码: #include<stdio.h> int main(){ int n, m, k; ]; while(~scanf("%d%d%d", &n, &m, &k)){ ; i<…
C. Bank Hacking 题目大意:给出一棵n个节点的树,每个节点有一个权值,删掉一个点的代价为当前这个点的权值,并且会使其相邻点和距离为2且中间隔着未被删除的点的点权值加1,现在选一个点开始删,之后每次能删掉被删过的点的相邻点,问删掉整棵树,删各节点花费的最大值最小是多少.(n<=300,000) 思路:确定第一个删的点之后,与这个点相邻的点的删除花费是原权值加1,其他点是原权值加2,把所有点权加2后枚举一个点减2再把相邻的减1,线段树统计答案后改回去,总复杂度O(nlogn),O(n)…