Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
bqi343 committed Dec 29, 2021
1 parent c19d918 commit 1a782e9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
13 changes: 8 additions & 5 deletions Implementations/content/geometry (13)/3D/Hull3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
* are coplanar. Normals to returned faces point outwards.
* If coordinates are ints at most $B$ then \texttt{T}
* should be large enough to support ints on the order
* of $B^3$. Changes order of points.
* of $B^3$. Changes order of points. WARNING: If there are
* coplanar points, the number of faces that are output will
* depend on the random seed, because points that are on the
* boundary of the convex hull may or may not be included
* in the output.
* Time: O(N^2), O(N\log N)
* Source:
* KACTL
Expand Down Expand Up @@ -63,10 +67,9 @@ V<F> hull3d(vP3& p) {
}
V<F> hull3dFast(vP3& p) {
prep(p); int N = sz(p); V<F> hull;
vb active; V<vi> rvis; V<AR<pi,3>> other;
// whether face is active
// points visible from each face
// other face adjacent to each edge of face
vb active; // whether face is active
V<vi> rvis; // points visible from each face
V<AR<pi,3>> other; // other face adjacent to each edge of face
V<vi> vis(N); // faces visible from each point
auto ad = [&](int a, int b, int c) {
hull.pb({a,b,c}); active.pb(1); rvis.eb(); other.eb(); };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

template<int SZ> struct UnweightedMatch {
int match[SZ], N; vi adj[SZ];
void ae(int u, int v) { adj[u].pb(v), adj[v].pb(u); }
void ae(int u, int v) { assert(u != v); adj[u].pb(v), adj[v].pb(u); }
queue<int> q;
int par[SZ], vis[SZ], orig[SZ], aux[SZ];
void augment(int u, int v) { // toggle edges on u-v path
Expand Down
16 changes: 9 additions & 7 deletions Other Implementations/06 - DP/LIS (6).cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
* Verification: https://cses.fi/problemset/task/1145/
*/

vi bes = {INT_MIN}; // min last term of increasing sequence with i terms

void add(int x) { // add terms of sequence one by one
int lo = lb(all(bes),x)-begin(bes);
if (lo == sz(bes)) bes.pb(0);
bes[lo] = x; // sz(bes)-1 is your current answer
}
int lis(vi v) {
vi min_last{INT_MIN}; // min last term of increasing sequence with i terms
for (int x: v) {
int lo = lb(all(min_last),x)-begin(min_last);
if (lo == sz(min_last)) min_last.pb(0);
min_last[lo] = x;
}
return sz(min_last)-1;
}

0 comments on commit 1a782e9

Please sign in to comment.