Coding question There are N soldiers standing in a line, with IDs from 1 to Nin ascending order

Viewed 40

There are N soldiers standing in a line, with IDs from 1 to Nin ascending order. They are participating in an exercise consisting of Q actions. During the ith action, the Major calls S numbers row, and col. The soldiers at the row, th and colth positions swap places; then the soldiers at (row+1)th and (col-1)th positions swap places, and so on until (row,+m)<(col-m). Each of the soldier's IDs will be covered in the range [row, col] for at most one action.

0 Answers
Related