Skip to content

Instantly share code, notes, and snippets.

View ynzwtks's full-sized avatar
😗

ynzwtks

😗
View GitHub Profile
@ynzwtks
ynzwtks / gist:7a9e7c1c44e02a7ef1e281a23ac5e423
Created January 17, 2025 12:04
nCkのイテレーション
func solve() {
n, k := 5, 3
perm := make([]int, k)
for i := 0; i < k; i++ {
perm[i] = i
}
var f func() bool
f = func() bool {
for ti := k - 1; ti >= 0; ti-- {
@ynzwtks
ynzwtks / bit.go
Created March 17, 2024 10:27
Bit操作(1次元、2次元データ構造)
package main
import (
"fmt"
"math/bits"
)
const (
INF = 1 << 60
)
@ynzwtks
ynzwtks / note.go
Created March 16, 2024 10:12
永続リスト
package main
import "fmt"
const (
INF = 1 << 60
)
type Note[T any] struct {
page *Page[T]
@ynzwtks
ynzwtks / KthPQ.go
Last active March 16, 2024 09:21
昇順(or 降順)要素K個の和を求める
package main
import (
"fmt"
"golang.org/x/exp/constraints"
"sort"
)
const (
INF = 1 << 60
@ynzwtks
ynzwtks / RemovablePQ.go
Last active March 16, 2024 08:32
削除可能な優先度付きキュー
package main
import (
"fmt"
"golang.org/x/exp/constraints"
)
const (
INF = 1 << 60
)
@ynzwtks
ynzwtks / pq.go
Created March 16, 2024 00:09
Prioriy Queue(ジェネリクスで汎化)
package main
import (
"fmt"
"golang.org/x/exp/constraints"
)
// 汎用Priority Queue
type PQ[T comparable] struct {
@ynzwtks
ynzwtks / KthSum.go
Last active March 15, 2024 23:11
キュー内の要素について昇順または降順でk番目までの和
package main
import (
"fmt"
"golang.org/x/exp/constraints"
"sort"
)
const (
INF = 1 << 60
@ynzwtks
ynzwtks / waveletmarix.go
Last active February 5, 2025 08:45
Wavelet Matrix
package main
import (
"fmt"
)
//-------------------- BitVector (1ビットを圧縮保持) --------------------//
type BitVector struct {
n int // ベクトル長
@ynzwtks
ynzwtks / dll.go
Last active March 10, 2024 02:40
 双方向リンクリストで要素の削除、挿入
package main
import "fmt"
// ABC344 E Insert or Erase
// https://atcoder.jp/contests/abc344/tasks/abc344_e
// List 双方向リンクリスト
type List[T comparable] struct {
first *element[T]
@ynzwtks
ynzwtks / LazySegmentTree.go
Last active March 10, 2024 13:39
遅延評価セグメント木(区間加算/区間更新の区間和/最小値/最大値)
package main
import (
"fmt"
)
const (
INF = 1 << 60
)