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

一点思路,不是很好,但不容易出错。

Posted by peterdi at 2009-05-21 12:37:03 on Problem 1363
规律:任意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:
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