题目链接:http://codeforces.com/problemset/problem/164/A 思路:用vector分别保留原图和发图,然后分别从val值为1的点正向遍历,va值为2的点反向遍历,如果某个点这两种方式都可以遍历到,则输出1,否则输出0. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <vector>…
VK Cup 2012 Round 3 (Unofficial Div. 2 Edition) 代码 VK Cup 2012 Round 3 (Unofficial Div. 2 Edition) A. Problem About Equation 每个杯子体积\[V=\frac{b+\sum{a_i}}{n}\] 判断是否有\(a_i > V\). B. File List 处理出'.'的位置. 第一个'.'和最后一个'.'特判字符长度是否合法. 连续的两点位置差\(d\in[2, 11]\)…
D. Distance in Tree time limit per test 3 seconds memory limit per test 512 megabytes input standard input output standard output A tree is a connected graph that doesn't contain any cycles. The distance between two vertices of a tree is the length (…
题目:http://codeforces.com/problemset/problem/161/D 题意:给你一棵树,问你两点之间的距离正好等于k的有多少个 思路:这个题目的内存限制首先大一倍,他有5*1e5个点,k的范围是<=500,首先暴力n^2肯定不行,这个题其实很容易看出是树形dp 首先k的范围只有500,我们可以开一个dp[1e5][500]的dp数组,代表以这个点为上端点的所有情况,然后最后递归到1点处,dp[1][k]就是答案 #include<cstdio> #inclu…
统计树中长度为K的路径条数. 用f[u][k]表示从u结点的子树中出发,终止于u结点的长度为k的路径条数. 边dp边统计答案.为了防止重复统计,在枚举子节点的时候,先将该子节点和当前u结点(和前面已经统计过的子节点)的dp值统计到ans以后, 再把该子节点的dp值加到u结点的dp值中去. 这样,我们统计经过某个结点的长度为K的路径条数的时候,可以保证路径的两个端点来自其两个不同的子树或其本身,这样也是为了防止重复统计. #include<cstdio> using namespace std;…
题目地址:http://blog.csdn.net/shiyuankongbu/article/details/10004443 /* 题意:在i前面找回文子串,在i后面找回文子串相互配对,问有几对 DP:很巧妙的从i出发向两头扩展判断是否相同来找回文串 dpr[i] 代表记录从0到i间的回文子串的个数,dpl[i] 代表记录i之后的回文子串个数 两两相乘就行了 详细解释:http://blog.csdn.net/shiyuankongbu/article/details/10004443 */…
VK Cup 2015 - Round 1 (unofficial online mirror, Div. 1 only)E. The Art of Dealing with ATM Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/529/problem/E Description ATMs of a well-known bank of a sm…
Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 全场题解 菜鸡只会A+B+C,呈上题解: A. Bear and Big Brother 题意:我也没看太清,就是给你两个10以内的数a,b.a每天乘以3,b每天乘以2,求多少天后a大于b. 思路:应该是有公式的,不过看到数据这么小直接暴力乘求解.官方题解貌似就是这样,数据小就是水题. const int N=1e3+10; int main() { int a…
C. Little Artem and Random Variable 题目连接: http://www.codeforces.com/contest/668/problem/C Description Little Artyom decided to study probability theory. He found a book with a lot of nice exercises and now wants you to help him with one of them. Cons…
A. Is it rated? time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Is it rated? Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to a…