F.A.Qs Home ProblemSet Status Ranklist Contest LoginRegister
Notice:1:注册本OJ方式请见https://www.lydsy.com/JudgeOnline/wttl/thread.php?tid=5671 2:请不要在讨论区中发空白主题帖。
大视野在线测评-欢迎您
[ New Thread ]
Problem 2783 >> 为什么我交洛古AC,交这却是TLE?
___t @ 2018-08-13 17:03:10
[ Quote ] [ Edit ] [ Delete ] 1#
#include<cstdio>
int n,s,x,y,f[100010][22],g[100010][22],ar[100010],ans;
int main()
{
scanf("%d%d",&n,&s);
for(int i=1;i<=n;i++)scanf("%d",ar+i);
for(int i=1;i<n;i++)
{
scanf("%d%d",&x,&y);
f[y][0]=x;
g[y][0]=ar[x];
}
for(int j=1;j<=19;j++)
for(int i=1;i<=n;i++)
{
f[i][j]=f[f[i][j-1]][j-1];
g[i][j]=g[i][j-1]+g[f[i][j-1]][j-1];
}
for(int i=1;i<=n;i++)
{
int tp=ar[i],temp=i;
if(tp==s)
{
ans++;
continue;
}
for(int j=19;j>=0;j--)
{
if(tp+g[temp][j]<s&&g[temp][j]!=0&&f[temp][j]!=0)
{
tp+=g[temp][j];
temp=f[temp][j];
}
if(tp+g[temp][j]==s)
{
ans++;
break;
}
}
}
return printf("%d",ans)&0;
}
QuartZ_Z @ 2018-08-13 20:51:51
[ Quote ] [ Edit ] [ Delete ] 2#
在bzoj的六元cpu上TLE不是很正常的吗?
i78700K @ 2018-08-13 21:36:38
[ Quote ] [ Edit ] [ Delete ] 3#
在bzoj的六元cpu上TLE不是很正常的吗?
nzhtl1477 @ 2018-08-14 00:13:29
[ Quote ] [ Edit ] [ Delete ] 4#
洛古
rilisoft @ 2018-08-17 23:21:22
[ Quote ] [ Edit ] [ Delete ] 5#
在bzoj的六元cpu上TLE不是很正常的吗?
zxc1234 @ 2018-08-19 13:58:40
[ Quote ] [ Edit ] [ Delete ] 6#
在bzoj的六元cpu上TLE不是很正常的吗?
2016gdgzoi471 @ 2018-08-19 18:20:47
[ Quote ] [ Edit ] [ Delete ] 7#
洛咕
rainman @ 2018-08-19 18:54:11
[ Quote ] [ Edit ] [ Delete ] 8#
在bzoj的六元cpu上TLE不是很正常的吗?
memset0 @ 2018-09-28 21:47:26
[ Quote ] [ Edit ] [ Delete ] 9#
在bzoj的六元cpu上TLE不是很正常的吗?
OwenOwl @ 2018-09-28 22:41:33
[ Quote ] [ Edit ] [ Delete ] 10#
BZOJ本质上是各路大神锻炼究极卡常的试炼地
lavendir @ 2018-09-29 10:20:19
[ Quote ] [ Edit ] [ Delete ] 11#
洛谷上是单点时限,这边开的是总时限。再者这个题有这么人过了,应该是没问题的啊。
[Top] [Previous Page] [Next Page]

HOME Back