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

Правка en3, от Naithani, 2020-08-22 14:14:16

Hello Codeforces, I was solving the problem, and I got 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:)

Теги #randomisation, random

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en3 Английский Naithani 2020-08-22 14:14:16 2 Tiny change: '), and I get the righ' -> '), and I got the righ'
en2 Английский Naithani 2020-08-22 13:47:31 0 (published)
en1 Английский Naithani 2020-08-22 13:46:40 624 Initial revision (saved to drafts)