解题报告poj1674交换排序.docxVIP

  • 0
  • 0
  • 约1.64千字
  • 约 3页
  • 2023-12-15 发布于上海
  • 举报

SortingbySwapping

TimeLimit:1000MS MemoryLimit:10000KTotalSubmissions:5760 Accepted:3033

Description

Givenapermutationofnumbersfrom1ton,wecanalwaysgetthesequence1,2,

3,...,nbyswappingpairsofnumbers.Forexample,iftheinitialsequenceis2,3,5,4,1,wecansorttheminthefollowingway:

23541

13542

13245

12345

Herethreeswapshavebeenused.Theproblemis,givenaspecificpermutation,howmanyswapsweneedstotakeatleast.

Input

Thefirstlinecontainsasingleintegert(1=t=20)thatindicatesthenumberoftestcases.Thenfollo

文档评论(0)

1亿VIP精品文档

相关文档