Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:只能做到16ms了,各位大牛帮忙看看还有哪能优化,附代码

Posted by lzqxh at 2010-08-21 00:56:03 on Problem 1143
In Reply To:只能做到16ms了,各位大牛帮忙看看还有哪能优化,附代码 Posted by:yzhw at 2010-01-30 11:03:29
if(refer[pos]) return refer[pos];
都说叫记忆化搜索咯。。就是搜索过不用再计算啦。。你干嘛只保留一个状态。
改一下用-1表示必败态。。1表示必胜态。。非0就不用搜索

void change(bool tar[],int pos)
的实现也可以优化。。
for (int i = pos+1; i<=20; i++) 
   if ( !tar[i-pos] ) tar[i] = false;

鄙人比较菜就发现这两个优化。。不过绝对可以到0ms的

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator