Skip to content
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

Add range_chmin_chmax_add_range_sum #257

Merged
merged 4 commits into from
Jan 8, 2020

Conversation

kmyk
Copy link
Contributor

@kmyk kmyk commented Jan 8, 2020

close #243

作りました。

  • 「常に |a_i| <= 10^12」という制約にしてあります (issue で確認し忘れてました)。
    • point_add_range_sum とかだと 0 <= a_i <= 10^9 なので非負にしたい気もしますが、「常に 0 <= a_i <= 10^12」だとぜんぶ非負に見えて負の加算クエリが来るのが罠っぽいのでまずいです。かといって「常に 0 <= a_i <= 10^12 かつ加算クエリは非負」は冗長なので、シンプルな「常に |a_i| <= 10^12」にしてあります。
    • point_add_range_sum でも a_i の値はクエリによって 10^9 を越えるので「常に |a_i| <= 10^9」ではなく「常に |a_i| <= 10^12」で問題ないはずです。
  • N = 1, 2, ..., 10 の場合を検証したい (N = 1 や N = 2^k-1, N = 2^k でバグりがち) のでそういうテストケースを足しています。argv[1] の値を使ってたりするので、まずかったら止めてください。
  • correct.cpp の正当性は naive.cpp の他に https://tjkendev.github.io/procon-library/cpp/range_query/segment_tree_beats_2.html を使って確認しています。

長さ $N$ の整数列 $a_0, a_1, \dots, a_{N - 1}$ が与えられる。

- `0 $l$ $r$ $b$ $c$`: 各 $i = l, l+1, \dots, {r - 1}$ について、$a_i = b \times a_i + c$
- `1 $l$ $r$`: $\sum_{i = l}^{r - 1} a_i \bmod {{param MOD}}$ を出力する。
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多分コピペ元を消し忘れてます

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正しました

@yosupo06
Copy link
Owner

yosupo06 commented Jan 8, 2020

ありがとうございます! 見ます

@kmyk
Copy link
Contributor Author

kmyk commented Jan 8, 2020

segtree.hpp を生やしたんですが gitignore されてて add し忘れてたので add しました。
ところで置き場所とか拡張子はこれでいいですか?

@yosupo06
Copy link
Owner

yosupo06 commented Jan 8, 2020

  • N = 1, 2, ..., 10 の場合を検証したい (N = 1 や N = 2^k-1, N = 2^k でバグりがち) のでそういうテストケースを足しています。argv[1] の値を使ってたりするので、まずかったら止めてください。

argv[1]を直接使うのは問題ないです

segtree.hpp を生やしたんですが gitignore されてて add し忘れてたので add しました。
ところで置き場所とか拡張子はこれでいいですか?

大丈夫です、実はどちらもあんまり気にしてないです(最悪includeをちょっといじれば変更できるはずなので)

int t = gen.uniform(0, 3);
int l, r;
tie(l, r) = gen.uniform_pair(0, n - 1);
r++;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(0, n)?(さっきの #253 )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修正しました (small.cpp だけ修正して他を忘れていました)

@yosupo06
Copy link
Owner

yosupo06 commented Jan 8, 2020

見ました、マージします ありがとうございます!

@yosupo06 yosupo06 merged commit 358de26 into yosupo06:master Jan 8, 2020
@yosupo06
Copy link
Owner

yosupo06 commented Jan 8, 2020

いやよく見たら実行時間がすごいことになっています N <= 200,000の方が良さそう(もうマージしましたが…)

@kmyk
Copy link
Contributor Author

kmyk commented Jan 8, 2020

手元で1.8秒とかだったから気にしてなかったが3秒を越えるのはつらそう 🙇

@yosupo06
Copy link
Owner

yosupo06 commented Jan 8, 2020

あれ、結構CI遅いんですね(手元が速い?)

@kmyk
Copy link
Contributor Author

kmyk commented Jan 8, 2020

CIが遅いのでなくて手元は速いはずです (新しめのデスクトップ機を使っています)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[問題案] Range Chmin Chmax Add Range Sum (range_chmin_chmax_add_range_sum)
2 participants