| ||||||||||
| 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 | |||||||||
Re:用DFS+剪枝的方法做的,为什么会无限的TLEIn Reply To:用DFS+剪枝的方法做的,为什么会无限的TLE Posted by:1176497071 at 2015-08-27 00:33:00 > void judge(int dx,int sumt)
> {
> if(sumt==sum/2)
> {
> stop=true;
> flag=true;
> return;
> }
> if(stop) return;
> for (int i=dx;i>=1;i--)
> {
> if(sumt>sum/2) return;
> if(coun[i]>=num[i]||num[i]==0) continue;
> if(stop) break;
> coun[i]++;
> judge(i,sumt+i);
> coun[i]--;
> if(stop) break;
> }
> }
>
> 其中dx是上一次加入的值,sumt是累加的值,coun数组用于记录1~6背包动态物品的数目。
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator