Let i denote the goods that the i-th dealer wants. So our goal is to get i in the i-th position.
For the sample input....
Initial state: 2 1 3 5 6 7 4
On day one, the exchanges are 1-2, 4-5, and 7-6.
State after day 1: 1 2 3 4 7 6 5
On day two, the exchange is 7-5.
State after day 2: 1 2 3 4 5 6 7
However the output specification states that the pairs are the "dealers who exchange their goods," not the goods which are exchanged. This is what confused me.
Can someone clarify this for me? Before looking for flaws in my algorithm or implementation, I'd like to make sure I correctly understood what I'm supposed to output.
created
last reply
- 31
replies
- 1.8k
views
- 13
users
- 1
link