Skip to content

Commit

Permalink
Customize
Browse files Browse the repository at this point in the history
  • Loading branch information
thepluck committed Oct 28, 2024
1 parent a78e5bc commit fc636ef
Show file tree
Hide file tree
Showing 15 changed files with 127 additions and 21 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ on:
branches: [ main ]

jobs:
build:

release:
runs-on: ubuntu-latest
timeout-minutes: 20

Expand All @@ -22,3 +21,11 @@ jobs:
run: make test-compiles
- name: Run stress tests
run: make test
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Latest build"
files: "kactl.pdf"

6 changes: 3 additions & 3 deletions content/contest/chapter.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ \chapter{Contest}

\kactlimport[-l rawcpp]{template.cpp}
\kactlimport[-l sh]{.bashrc}
\kactlimport[-l raw]{.vimrc}
\kactlimport[-l raw]{hash.sh}
\kactlimport[-l raw]{troubleshoot.txt}
% \kactlimport[-l raw]{.vimrc}
% \kactlimport[-l raw]{hash.sh}
% \kactlimport[-l raw]{troubleshoot.txt}
14 changes: 13 additions & 1 deletion content/data-structures/MoQueries.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,22 @@ void add(int ind, int end) { ... } // add a[ind] (end = 0 or 1)
void del(int ind, int end) { ... } // remove a[ind]
int calc() { ... } // compute current answer

ull hilbert(ull x, ull y) {
const ull logn = __lg(max(x, y) * 2 + 1) | 1;
const ull maxn = (1ull << logn) - 1;
ull res = 0;
for (ull s = 1ull << (logn - 1); s; s >>= 1) {
bool rx = x & s, ry = y & s;
res = (res << 2) | (rx ? ry ? 2 : 1 : ry ? 3 : 0);
if (!rx) { if (ry) x ^= maxn, y ^= maxn; swap(x, y); }
}
return res;
}

vi mo(vector<pii> Q) {
int L = 0, R = 0, blk = 350; // ~N/sqrt(Q)
vi s(sz(Q)), res = s;
#define K(x) pii(x.first/blk, x.second ^ -(x.first/blk & 1))
#define K(x) hilbert(x.first, x.second)
iota(all(s), 0);
sort(all(s), [&](int s, int t){ return K(Q[s]) < K(Q[t]); });
for (int qi : s) {
Expand Down
6 changes: 3 additions & 3 deletions content/data-structures/chapter.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ \chapter{Data structures}
\kactlimport{LazySegmentTree.h}
% \kactlimport{UnionFind.h}
\kactlimport{UnionFindRollback.h}
\kactlimport{SubMatrix.h}
% \kactlimport{SubMatrix.h}
\kactlimport{Matrix.h}
\kactlimport{LineContainer.h}
\kactlimport{Treap.h}
\kactlimport{FenwickTree.h}
% \kactlimport{FenwickTree.h}
\kactlimport{FenwickTree2d.h}
\kactlimport{RMQ.h}
% \kactlimport{RMQ.h}
\kactlimport{MoQueries.h}
8 changes: 4 additions & 4 deletions content/geometry/chapter.tex
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ \section{Geometric primitives}
\kactlimport{sideOf.h}
\kactlimport{OnSegment.h}
\kactlimport{linearTransformation.h}
% \kactlimport{LineProjectionReflection.h}
\kactlimport{LineProjectionReflection.h}
\kactlimport{Angle.h}

\section{Circles}
\kactlimport{CircleIntersection.h}
\kactlimport{CircleTangents.h}
% \kactlimport{CircleLine.h}
\kactlimport{CircleLine.h}
\kactlimport{CirclePolygonIntersection.h}
\kactlimport{circumcircle.h}
\kactlimport{MinimumEnclosingCircle.h}
Expand All @@ -25,15 +25,15 @@ \section{Polygons}
\kactlimport{PolygonArea.h}
\kactlimport{PolygonCenter.h}
\kactlimport{PolygonCut.h}
% \kactlimport{PolygonUnion.h}
\kactlimport{PolygonUnion.h}
\kactlimport{ConvexHull.h}
\kactlimport{HullDiameter.h}
\kactlimport{PointInsideHull.h}
\kactlimport{LineHullIntersection.h}

\section{Misc. Point Set Problems}
\kactlimport{ClosestPair.h}
% \kactlimport{ManhattanMST.h}
\kactlimport{ManhattanMST.h}
\kactlimport{kdTree.h}
% \kactlimport{DelaunayTriangulation.h}
\kactlimport{FastDelaunay.h}
Expand Down
6 changes: 3 additions & 3 deletions content/kactl.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
\usepackage{kactlpkg}
\kactlcontentdir{content}

\university{KTH}{KTH Royal Institute of Technology}{kth}
\team{Omogen Heap}{Simon Lindholm, Johan Sannemo, Mårten Wiman}
\university{UET}{VNU University of Engineering and Technology}{uet}
\team{IBM Cloud}{Vu Nguyen Hoang, Chau Vu Minh, Hoang Vu Huy}
% \contest{ACM-ICPC World Finals 2017}{May 24, 2017}
\contest{\ }{\today}
% \enablecolors
Expand Down Expand Up @@ -31,6 +31,6 @@
\end{multicols*}

\begin{multicols*}{3}
\kactlchapter{appendix}
% \kactlchapter{appendix}
\end{multicols*}
\end{document}
2 changes: 1 addition & 1 deletion content/number-theory/Factor.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
*/
#pragma once

#include "ModMulLL.h"
#include "ModMul.h"
#include "MillerRabin.h"

ull pollard(ull n) {
Expand Down
2 changes: 1 addition & 1 deletion content/number-theory/MillerRabin.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
#pragma once

#include "ModMulLL.h"
#include "ModMul.h"

bool isPrime(ull n) {
if (n < 2 || n % 6 % 4 != 1) return (n | 1) == 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,32 @@
*/
#pragma once

typedef unsigned int uint;
typedef unsigned long long ull;
uint modmul(uint a, uint b, uint M) {
#ifdef _WIN32
ull x = ull(a) * ull(b);
uint xh = uint(x >> 32), xl = uint(x), d, m;
asm("divl %4; \n\t" : "=a"(d), "=d"(m)
: "d"(xh), "a"(xl), "r"(M()));
return m;
#else
uint ret;
asm("mul %%ebx\ndiv %%ecx\nmov %%edx, %0\n"
: "=ret"(ret): "a"(a), "b"(b), "c"(M): "edx");
return ret;
#endif
}
ull modmul(ull a, ull b, ull M) {
#ifdef _WIN32
ll ret = a * b - M * ull(1.L / M * a * b);
return ret + M * (ret < 0) - M * (ret >= (ll)M);
#else
ull ret;
asm("mul %%rbx\ndiv %%rcx\n" : "=d"(ret)
: "a"(a), "b"(b), "c"(M));
return ret;
#endif
}
ull modpow(ull b, ull e, ull mod) {
ull ans = 1;
Expand Down
4 changes: 2 additions & 2 deletions content/number-theory/chapter.tex
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
\chapter{Number theory}

\section{Modular arithmetic}
\kactlimport{ModularArithmetic.h}
% \kactlimport{ModularArithmetic.h}
\kactlimport{ModInverse.h}
\kactlimport{ModPow.h}
\kactlimport{ModLog.h}
\kactlimport{ModSum.h}
\kactlimport{ModMulLL.h}
\kactlimport{ModMul.h}
\kactlimport{ModSqrt.h}

\section{Primality}
Expand Down
25 changes: 25 additions & 0 deletions content/strings/PalindromicTree.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Author: adamant
* Date: 2024-10-24
* License: CC0
* Source: https://codeforces.com/blog/entry/13959
* Description: Builds palindromic tree for a string.
* Status: stress-tested
*/

const int N = 1e5, sigma = 26;
int s[N], len[N], link[N], to[N][sigma], n, last, sz;
void init() {s[n++] = -1; link[0] = 1; len[1] = -1; sz = 2;}
int get_link(int v) {
while (s[n - len[v] - 2] != s[n - 1]) v = link[v];
return v;
}
void add_letter(int c) {
s[n++] = c; last = get_link(last);
if (!to[last][c]) {
len[sz] = len[last] + 2;
link[sz] = to[get_link(link[last])][c];
to[last][c] = sz++;
}
last = to[last][c];
}
40 changes: 40 additions & 0 deletions content/strings/SuffixAutomaton.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Author: minhnhatnoe
* Date: 2022-11-12
* License: CC0
* Source: minhnhatnoe and tuanlinh123
* Description: Suffix Automaton, supporting multiple strings.
* The beginning iterator is $0$. Make calls to itmove to progress iterator.
* Time: O(n)
* Status: stress-tested
*/

struct SuffixAutomaton{
struct Node{
int len, link = -1, nxt[26];
Node(int len): len(len) {fill(nxt, nxt + 26, -1);}
Node(int len, int link, int _nxt[26]):
len(len), link(link) {memcpy(nxt, _nxt, sizeof nxt);}
};
vector<Node> g = {0};
int ptrans(int p, char c, int nxt) {
for (int q = g[p].nxt[c]; p != -1 && g[p].nxt[c] == q;
p = g[p].link) g[p].nxt[c] = nxt;
return p;
}
int fbuild(int p, char c) {
if (p == -1) return 0;
int q = g[p].nxt[c];
if (g[p].len + 1 == g[q].len) return q;
int qc = g.size();
g.emplace_back(g[p].len+1, g[q].link, g[q].nxt);
ptrans(p, c, qc); return g[q].link = qc;
}
int addc(int p, char c) { // Progress iterator
if (g[p].nxt[c] != -1) return fbuild(p, c);
int nc = g.size();
g.emplace_back(g[p].len+1);
int r = fbuild(ptrans(p, c, nc), c);
g[nc].link = r; return nc;
}
};
Binary file removed content/tex/kth.pdf
Binary file not shown.
Binary file added content/tex/uet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "../utilities/template.h"

#include "../../content/number-theory/ModMulLL.h"
#include "../../content/number-theory/ModMul.h"

const int ITERS = 5'000'000; // (not really enough to say much, need >1e10 for any kind of certainty)

Expand Down

0 comments on commit fc636ef

Please sign in to comment.