-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
127 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
title: Dynamic Point Add Rectangle Sum | ||
documentation_of: //other/dynamic-point-add-rectangle-sum.hpp | ||
|
||
--- | ||
|
||
2 次元平面上に重み付きの点を追加するクエリと、長方形内に含まれる点の重みの総和を求めるいくつかのクエリに答えます。 | ||
|
||
# コンストラクタ | ||
|
||
```cpp | ||
(1) DynamicPointAddRectangleSum< T, C >() | ||
(2) DynamicPointAddRectangleSum< T, C >(int q) | ||
``` | ||
|
||
`T` は座標が収まる型、$C$ は重みの総和が収まる型を指定してください。 | ||
|
||
(2) でクエリの個数 $q$ を指定した場合、領域を `reserve` するので少しだけ効率的です。 | ||
|
||
# add_point | ||
|
||
```cpp | ||
void add_point(T x, T y, C w) | ||
``` | ||
$(x, y)$ に重み $w$ の点を追加するクエリを追加します。 | ||
# 計算量 | ||
- $O(1)$ | ||
# add_query | ||
```cpp | ||
void add_query(T l, T r, T d, T u) | ||
``` | ||
|
||
$\lbrace (x,y):l \leq x \lt r, d \leq y \lt u\rbrace$ で表される長方形内にある点の重みの総和を求めるクエリを追加します。 | ||
|
||
## 制約 | ||
|
||
- $l \lt r$ | ||
- $r \lt u$ | ||
|
||
# 計算量 | ||
|
||
- $O(1)$ | ||
|
||
# calculate_queries | ||
|
||
```cpp | ||
vector<C> calculate_queries() const | ||
``` | ||
|
||
それぞれのクエリの答えを返します。$i$ 番目の要素は $i$ 番目に追加したクエリの答えが格納されます。 | ||
|
||
## 計算量 | ||
|
||
- $O(q \log^2 q)$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
--- | ||
title: Static Point Add Rectangle Sum | ||
documentation_of: //other/static-point-add-rectangle-sum.hpp | ||
|
||
--- | ||
|
||
2 次元平面上に重み付きの点が与えられます。 | ||
|
||
長方形内に含まれる点の重みの総和を求めるいくつかのクエリに答えます。 | ||
|
||
# コンストラクタ | ||
|
||
```cpp | ||
(1) StaticPointAddRectangleSum< T, C >() | ||
(2) StaticPointAddRectangleSum< T, C >(int n, int q) | ||
``` | ||
|
||
`T` は座標が収まる型、$C$ は重みの総和が収まる型を指定してください。 | ||
|
||
(2) で点の個数 $n$、クエリの個数 $q$ を指定した場合、領域を `reserve` するので少しだけ効率的です。 | ||
|
||
# add_point | ||
|
||
```cpp | ||
void add_point(T x, T y, C w) | ||
``` | ||
$(x, y)$ に重み $w$ の点を追加します。 | ||
# 計算量 | ||
- $O(1)$ | ||
# add_query | ||
```cpp | ||
void add_query(T l, T r, $ d, $ u) | ||
``` | ||
|
||
$\lbrace (x,y):l \leq x \lt r, d \leq y \lt u\rbrace$ で表される長方形内にある点の重みの総和を求めるクエリを追加します。 | ||
|
||
## 制約 | ||
|
||
- $l \lt r$ | ||
- $r \lt u$ | ||
|
||
# 計算量 | ||
|
||
- $O(1)$ | ||
|
||
# calculate_queries | ||
|
||
```cpp | ||
vector<C> calculate_queries() const | ||
``` | ||
|
||
それぞれのクエリの答えを返します。$i$ 番目の要素は $i$ 番目に追加したクエリの答えが格納されます。 | ||
|
||
## 計算量 | ||
|
||
- $O((n + q) \log (n + q))$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters