-
-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
random.h の uniform_pair がなんだか変 #253
Comments
ありがとうございます、ああー大惨事… 空でない区間[l, r)を生成する用途がほとんどのはずなんですが、uniform / uniform_pairが並んでいて区間の開閉が違うと困惑するんじゃないかと思ってこうしています(uniformはuniform_int_distributonに合わせて閉区間にした) 現に失敗していますが |
ランダムな2点を返すという設計はあまりおかしくない気がしてしました [l, r) から空でないランダムな半開区間を選ぶ はuniform_pair(l, r)で、実はそのまま対応しています |
なので、実は仕様変更するまでもなくkimiyukiさんの提案した仕様になっていて、使い方を完全に間違えていた が正しい気がしています😖 |
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
random.h
のuniform_pair
は現状次のようになっています。コメントは
な感じですが、実装は
です。
library-checker-problems/common/random.h
Lines 79 to 90 in 800d18c
そして実際の使われ方には (1.) を想定しているものがほぼすべてで、結果として微妙にバグってます。
たとえば point_add_range_sum の
random.cpp
では以下のように使われているんですが、以下の問題があります。assert
で落ちる。library-checker-problems/datastructure/point_add_range_sum/gen/random.cpp
Lines 27 to 28 in 800d18c
ところで、どうせ仕様変更するなら、用途を考えると (3.) 「空でない半開区間 [l, r) から空でない部分区間を返す」にしたい気もします。
The text was updated successfully, but these errors were encountered: