-
Notifications
You must be signed in to change notification settings - Fork 2
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
Merge Sort Tree #106
Merge Sort Tree #106
Conversation
cpp/merge-sort-tree.hpp
Outdated
} | ||
} | ||
|
||
if (i < n) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i < n
じゃないことはありますか。
cpp/merge-sort-tree.hpp
Outdated
} | ||
} | ||
|
||
value_type _prod_section(int l, int r, std::optional<key_type> a, std::optional<key_type> b) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aもbもnullならeではなく総積を返してほしくないですか。
初期値を総積にしておいてbのほうもhas_value()
で右側範囲の逆元をかけると良いと思います。
cpp/merge-sort-tree.hpp
Outdated
int last1 = j2; | ||
int last2 = h * sz + std::min(n, i + t * 2); | ||
while (j1 != last1 or j2 != last2) { | ||
if (j1 == last1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
特別気にしないのでそのままでもいいですが、同じことが2回ずつ書いてあると写経でミスする可能性が大きくなるのでj1 == last || (j2 < last && cmp(key_data[j2], key_data[j1])
などとすると簡潔そうです。
cpp/merge-sort-tree.hpp
Outdated
/** | ||
* @brief product value[i] s.t. a <= key[i] < b , i in [l, r) | ||
*/ | ||
value_type prod(std::optional<int> l = std::nullopt, std::optional<int> r = std::nullopt, std::optional<key_type> a = std::nullopt, std::optional<key_type> b = std::nullopt) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
セグ木にassertを入れたのでここでも入れると良さそうです。
指摘を反映しました。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OKです
No description provided.