Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
rsk0315 committed Jan 20, 2024
1 parent d87ecf8 commit 00177ce
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nekolib-doc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ algo = { path = "../nekolib-src/algo" }
naive = { path = "../nekolib-src/naive" }
corro = { path = "../nekolib-src/corro" }
random = { path = "../nekolib-src/random" }
snippet = { path = "../nekolib-src/snippet" }
discussion = { path = "../nekolib-src/discussion" }
31 changes: 31 additions & 0 deletions nekolib-doc/katex.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,37 @@
const macros = {
// '\\foo': '42',
// '\\bar': '\\operatorname{bar}^{#1}',
'\\halfopen': '[#1, #2)',
'\\floor': '\\lfloor #1\\rfloor',
'\\ceil': '\\lceil #1\\rceil',
'\\rounded': '\\lfloor #1\\rceil',
'\\Floor': '\\left\\lfloor #1\\right\\rfloor',
'\\Ceil': '\\left\\lceil #1\\right\\rceil',
'\\Rounded': '\\left\\lfloor #1\\right\\rceil',
'\\angled': '\\langle #1\\rangle',
'\\Angled': '\\left\\langle #1\\right\\rangle',
'\\lcm': '\\operatorname*{lcm}',
'\\gcd': '\\operatorname*{gcd}',
'\\poly': '\\operatorname{poly}',
'\\polylog': '\\operatorname{polylog}',
'\\concat': '\\mathrel{+\\!\\!+}',
'\\mex': '\\operatorname*{mex}',
'\\qed': '\\square',
'\\Q': '\\mathbb{Q}',
'\\dd': '\\mathrm{d}',
'\\ForallL': '{}^{\\forall}#1.\\:#2',
'\\Forall': '{}^{\\forall}#1.\\,\\left[#2\\right]',
'\\ExistsL': '{}^{\\exists}#1.\\:#2',
'\\Exists': '{}^{\\exists}#1.\\,\\left[#2\\right]',
'\\roundp': '(\\kern-.2em[#1]\\kern-.2em)',
'\\bigroundp': '\\big(\\kern-.25em\\big[#1\\big]\\kern-.25em\\big)',
'\\Bigroundp': '\\Big(\\kern-.3em\\Big[#1\\Big]\\kern-.3em\\Big)',
'\\biggroundp': '\\bigg(\\kern-.3em\\bigg[#1\\bigg]\\kern-.3em\\bigg)',
'\\Biggroundp': '\\Bigg(\\kern-.35em\\Bigg[#1\\Bigg]\\kern-.35em\\Bigg)',
'\\hfloor': '\\lfloor\\hspace{-.25em}\\lfloor#1\\rfloor\\hspace{-.25em}\\rfloor',
'\\xgets': '\\xleftarrow{#1}',
'\\eod': '\\blacksquare', // end of \<details\>
'\\lldot': '\\mathop{.\\,.}',
};

document.addEventListener('DOMContentLoaded', () => {
Expand Down
2 changes: 2 additions & 0 deletions nekolib-doc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pub use {
algo,
corro,
discussion,
ds,
fmt,
integer,
Expand All @@ -13,5 +14,6 @@ pub use {
poc,
random,
seq,
snippet,
uslice,
};
11 changes: 11 additions & 0 deletions nekolib-src/discussion/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
workspace = { members = ["plane-sweep"] }
[package]
name = "discussion"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
inner = { path = "../inner" }
plane-sweep = { path = "plane-sweep" }
8 changes: 8 additions & 0 deletions nekolib-src/discussion/plane-sweep/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "plane-sweep"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
28 changes: 28 additions & 0 deletions nekolib-src/discussion/plane-sweep/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//! 平面走査。
//!
//! ## Idea
//!
//! 可換モノイド $`(S, \circ, e)`$ がある。
//! $`n`$ 個の相異なる点 $`(y_i, x_i)`$ と $`f(i) \in S`$ が与えられる。
//! 必要に応じて座標圧縮などを行うことで、$`x_i\in[0\lldot n)`$ とする。
//! このとき、$`y\in[-\infty\lldot y_r)`$ かつ $`x\in[x_l\lldot x_r)`$ なる点たちにおける
//! $`\circ`$ での fold を高速に求めたい。
//!
//! $`a = (a_0, a_1, \dots, a_{n-1})`$ で初期化し、$`y`$ の昇順[^1]に点を処理する。
//! $`a_{x_i} \xgets{\circ} f(i)`$ で更新しつつ、$`y\lt y_r`$ について処理し終えたら
//! $`a_{x_l}\circ\dots\circ a_{x_r-1}`$ を求めればよい。
//!
//! [^1]: 必要に応じてソート順は変更してもよい。
//!
//! $`(S, \circ)`$ が逆元を持つ状況では、適切に点を追加することで $`y\in[y_l\lldot y_r)`$
//! での fold を求めることもできる。
//!
//! ## Applications
//!
//! 点 $`(y_i, x_i)`$ に対し、$`y_j \lt y_i`$ かつ $`x_j \lt x_i`$ なる点 $`(y_j, x_j)`$ であって
//! $`f(j) \lt f(i)`$ なるものが存在するか?という問題を考える ([ABC 309 F])。
//!
//! [ABC 309 F]: https://atcoder.jp/contests/abc309/tasks/abc309_f
//!
//! ある $`j\in[0\lldot n)`$ に対して $`f(j)\lt f(i)`$ というのは $`\min_{j\in[0\lldot n)} f(j)\lt f(i)`$
//! と言い換えることができる。よって、$`(S, \min, \infty)`$ について上記の枠組みを適用することで解ける。
5 changes: 5 additions & 0 deletions nekolib-src/discussion/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use inner::doc_inline_reexport;

doc_inline_reexport! {
plane_sweep,
}

0 comments on commit 00177ce

Please sign in to comment.