| ||||||||||
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 |
一点思路,不是很好,但不容易出错。规律:任意i若出栈,则1~i-1的状态应为在栈中或已出栈,i+1~N的状态应为已出栈或未入栈。 设状态数组s[N],0表示未入栈 1表示在栈中 2表示已出栈。 对所有的输入刷新s[N]:输入i s[i]=2; 若s[1~i-1]==0,s[1~i-1]=1; 如果有k=i+1~N,s[k]==1,则不能按该顺序出栈,否则该输入安全; 所有输入都安全那么,可以按该顺序出栈。 Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator