| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
题目好水,我是以座标DP的,最后一个点不一定要走,只要前面的点走过来可以超过后面的点也算的。dp[i]代表飞到座标i的最少步数
for(i=1;i+1<n;i++)
{
if(p[i].y<p[0].y)continue;
lim=p[i].y*p[i].y-(p[i].y-p[0].y)*(p[i].y-p[0].y);
for(j=0;j*j<=lim&&p[i].x-j>=p[0].x;j++)
{
if(dp[p[i].x-j]!=INF)
{
int st=p[i].x+j;
if(st>p[n-1].x)st=p[n-1].x;
if(dp[p[i].x-j]+1<dp[st])
{
dp[st]=dp[p[i].x-j]+1;
}
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator