Codeforces 459E Roland and Rose】的更多相关文章

本以为是个树形DP,按照树形DP的方法在那里dfs,结果WA到死,因为它存在有向环,不是树,凡是存在环的情况切记不要用树形的方法去做 题目的突破点在于将边排完序之后,用点表示以该点为边结尾的最大长度,因为是按边排序从小到大加边,所以后面加的边肯定比前面的小. 要注意相同边的情况,要搞个缓冲,因为相同边的时候如果直接操作,可能会造成不应该有的影响. #include <iostream> #include <cstdio> #include <cstring> #incl…
题目链接:Codeforces 460E Roland and Rose 题目大意:在以原点为圆心,半径为R的局域内选择N个整数点,使得N个点中两两距离的平方和最大. 解题思路:R最大为30.那么事实上距离圆心距离最大的整数点只是12个最多,直接暴力枚举. #include <cstdio> #include <cstring> #include <vector> #include <algorithm> using namespace std; struc…
E. Roland and Rose Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/460/E Description Roland loves growing flowers. He has recently grown a beautiful rose at point (0, 0) of the Cartesian coordinate system. The ro…
codeforces 459E E. Pashmak and Graph time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pashmak's homework is a problem about graphs. Although he always tries to do his homework completely, he…
题目链接:Codeforces 459E Pashmak and Graph 题目大意:给定一张有向图,每条边有它的权值,要求选定一条路线,保证所经过的边权值严格递增,输出最长路径. 解题思路:将边依照权值排序,每次将同样权值的边同一时候增加,维护每一个点作为终止点的最大长度就可以. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn…
http://www.codeforces.com/problemset/problem/459/E 题意: 给出n个点,m条边的有向图,每个边有边权,求一条最长的边权上升的路径的长度. 思路:用f存边,g存点,然后排序转移,注意相同的要延迟转移 #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> #include<iostream> struct edge…
题目链接:http://codeforces.com/problemset/problem/459/E 题意: 给你一个有向图,每条边有边权. 让你找出一条路径,使得这条路径上的边权严格递增. 问你这样的路径最长有多长. 题解: 先将所有边按边权从小到大排序,以保证边权递增. 表示状态: dp[i] = max len 表示以点i为终点时的最长路径长度. 找出答案: ans = max dp[i] 如何转移: 枚举每条边e[i],则有: dp[e[i].t] = max(dp[e[i].t],…
E. Pashmak and Graph time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pashmak's homework is a problem about graphs. Although he always tries to do his homework completely, he can't solve thi…
题意:给定$n$和$r$,要找$n$个整点,使得他们两两距离的平方和最大,并且所有点到原点的距离必须小于$r$ 很容易猜到答案在凸包上然后暴力找,但证明还是挺妙的 首先转化一下距离平方和 令$\vec{a_i}=\vec{OA_i}$,则$\sum\limits_{i\lt j}A_iA_j^2=\dfrac{\sum\limits_{i\neq j}A_iA_j^2}{2}=\dfrac{\sum\limits_{i\neq j}(\vec{a_i}-\vec{a_j})^2}{2}=\dfr…
题目链接: E. Pashmak and Graph time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pashmak's homework is a problem about graphs. Although he always tries to do his homework completely, he can't sol…