Best way to pick index in array randomly in C++?

Revision en2, by Naithani, 2020-08-22 13:47:31

Hello Codeforces, I was solving the problem, and I get the right idea, but there was a problem with choosing the index randomly using uniform_int_distribution<int>.

sol1: This gives me WA at test case 32 because I was trying to pick index directly.

sol2: Now, at this time I pick randomly with lower_bound, and it worked.

Is there any better way to choose index uniformly and randomly?

Thanks in advance:)

Tags #randomisation, random

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English Naithani 2020-08-22 14:14:16 2 Tiny change: '), and I get the righ' -> '), and I got the righ'
en2 English Naithani 2020-08-22 13:47:31 0 (published)
en1 English Naithani 2020-08-22 13:46:40 624 Initial revision (saved to drafts)