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

可以先把它们按大小标记为1-n,然后使用复位法

Posted by Tonsty at 2010-04-11 00:06:22 on Problem 1804
In Reply To:如果这道题,不是相邻的数字swap,是允许任意位置的数据都可以swap,如何求解 Posted by:woodworker at 2010-01-21 14:25:40
如5 4 1 3 2 7 6 8
第一个是5,找到第五个是2,找到第二个是4,找到第四个是3,找到第三个是1,找到第1个是五,这样就是一个环,7和6同样构成一个环,8是个单环,用总数8减去环数3即是最少需要的swap交换数。可以自己证明一下。

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