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

请教括号问题1141

Posted by 5040309511 at 2007-09-25 01:48:36
我用的不是DP,而是用两次遍历,但是结果是WRONG ANSWER。

第一遍,当出现一个“]”并且前面无"空闲"的"["时,产即补上一个“[”。对“)”类似。并且处理“[)”和“(]”这种情况,做法是变成“[])”和“()]”继续。
第二遍,把未匹配的“(”和“[”匹配掉。

其中的一些细节也考虑了,试了几个数据也没有问题,包括WEB BOARD上的((]](][[](((][](]([[[[([]][(((([([[](]][([([[([](]((][[]([]]](([[]](]]([([]([[[([([][(]((][[(](]([[(
这个例子,结果是再需要50个括号。
我的输出是
()()[][]()[][[]()()()][]()[]()[][][][()[]][()()()()[()[[]()]][()[()[[()[]()]()()][[]()[]]]()()[[]]()]]()[]()[]()[][][]()[()[][()]()()][[()]()]()[][]()
前面有人给出的是
(([]))[]([])[[]]((()))[]([])([[[[([])]]]])[(((([([[]])]))))]()[([([[([])]])])]()(())[[]]([])(([[]]))()([([])])([[[([([])])]]])[()](())[[()]]()([[()]])

虽然不一样,但是括号也区配,顺序也对,为什么就WRONG ANSWER呢?请达人指教!

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