Skip to content

Instantly share code, notes, and snippets.

View RYNO8's full-sized avatar
👀
I lost the game

RYNO8

👀
I lost the game
View GitHub Profile
@Techno-coder
Techno-coder / segment_tree.cpp
Created January 9, 2021 02:57
Minimum Segment Tree
int next_binary_power(int x) {
return 1 << (32 - __builtin_clz(x - 1));
}
struct SegmentTree {
vector<int> nodes;
SegmentTree(int size) : nodes(next_binary_power(size) * 2, INT_MAX) {}
int query(int left, int right) {
@spdskatr
spdskatr / hungarian.cpp
Created October 10, 2020 11:08
Hungarian Algorithm O(N^4) implementation in C++
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <vector>
#include <utility>
#include <set>
using namespace std;
@paniq
paniq / minmaxabssign.txt
Last active January 30, 2023 14:31
useful min/max/abs/sign identities
max(-x,-y) = -min(x,y)
min(-x,-y) = -max(x,y)
abs(x) = abs(-x)
abs(x) = max(x,-x) = -min(x,-x)
abs(x*a) = if (a >= 0) abs(x)*a
(a < 0) -abs(x)*a
// basically any commutative operation
min(x,y) + max(x,y) = x + y