mannyamorim / CCC-Website

This repository is a Hugo website hosting editorial solutions for the Waterloo Canadian Computing Competition (CCC).
https://ccc.amorim.ca/
0 stars 0 forks source link

Problem in the article "2020-S4 Swapping Seats" #1

Open AlexOldest opened 2 months ago

AlexOldest commented 2 months ago

I found your detailed explanation and the code at https://ccc.amorim.ca/docs/2020/s4/ Thank you for all your works that I found on this site. Analyzing the code of function: static int compute_swaps(counts total, counts a, counts b, counts c) I noticed that:

  1. The first parameter (total) is never used within the function body. It does not bother me (just noticed).
  2. Within the body of this function you try to change the last two parameters (b and c) but this has no effect because you work with copies (structs were sent by value). I tried to modify the code (to send them by reference) but this led to an incorrect result for (the only) test sample. It would be good to see some explanation or fix because the problem is very challenging and the logic behind your solution is rather intricate.
AlexOldest commented 2 months ago

Sorry, I was wrong about the uselessness of sending structs by value and trying to change them. The changes will not have effect outside the function, but now I see that you use one of these changes within the function.