Skip to content

Instantly share code, notes, and snippets.

View Sd-Invol's full-sized avatar

Xuanang Zhao Sd-Invol

View GitHub Profile
@Sd-Invol
Sd-Invol / ABC280H.cc
Created December 27, 2022 10:32
SA + Cartesian tree
#include <bits/stdc++.h>
using int64 = long long;
const int Q = 998244353;
void induced_sort(const std::vector<int> &vec, int val_range,
std::vector<int> &SA, const std::vector<bool> &sl,
const std::vector<int> &lms_idx) {
std::vector<int> l(val_range, 0), r(val_range, 0);
for (int c : vec) {
if (c + 1 < val_range)
#include <bits/stdc++.h>
using int64 = long long;
const int N = 10005;
struct Point {
int x, y;
Point(int x = 0, int y = 0) : x(x), y(y) {}
bool operator<(const Point& rhs) {
return x != rhs.x ? x < rhs.x : y < rhs.y;
}
#include <bits/stdc++.h>
using uint64 = unsigned long long;
const int N = 100000;
const uint64 inv5 = 14757395258967641293ULL;
const uint64 inv55 = inv5 * inv5 * inv5 * inv5 * inv5;
struct Polynomial {
uint64 a[5]; // w10 ^ {0 .. 4}
@Sd-Invol
Sd-Invol / factorial.cc
Created September 25, 2022 12:30
Decomposition of a factorial to a * 2^k mod 2^64
#include <bits/stdc++.h>
using int64 = unsigned long long;
typedef std::vector<int64> poly;
const int M = 1024;
int64 comb[64][64], ok[M];
poly operator*(const poly& A, const poly& B) {
poly C(64);
@Sd-Invol
Sd-Invol / sv.sh
Created June 21, 2022 12:40
Detect website changes
a=$(curl https://www.pokemon.co.jp/ex/sv/sc/ | md5)
while :
do
sleep 15
b=$(curl https://www.pokemon.co.jp/ex/sv/sc/ | md5)
if [ $a != $b ]
then
echo "SV website updated!"
tput bel
break
@Sd-Invol
Sd-Invol / icpc-2020-editorial.md
Created October 6, 2021 05:05
ICPC WF 2020 部分题解

WF 2020

理解题意后,不难理解枚举 $p$ 之后,一次洗牌实际上对应的是行号到行号的映射,其中一定存在不动点。问题可以拆分为:

  • 判断不动点是否唯一
    • 不动点一定是连续的,解方程求出一个之后判断一下后一个是否还是不动点即可
  • 求收敛到不动点的最大轮数
  • 最晚收敛到不动点的一定是第 1 行或第 n 行,证明略。
@Sd-Invol
Sd-Invol / cloudSettings
Last active October 4, 2021 06:47
VS Code
{"lastUpload":"2021-10-04T06:47:46.257Z","extensionVersion":"v3.4.3"}
@Sd-Invol
Sd-Invol / memory_friendly_trie.cc
Created December 28, 2019 16:51
Trie with O(sigma * N / W) space. hdu5880
#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
const int M = 400005;
const int SIGMA = 26;
int pct[1 << 13];
inline int popcount(int x) {
return pct[x >> 13] + pct[x & 8191];
}
;; Added by Package.el. This must come before configurations of
;; installed packages. Don't delete this line. If you don't want it,
;; just comment it out by adding a semicolon to the start of the line.
;; You may delete these explanatory comments.
(require 'package) ;; You might already have this line
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(when (< emacs-major-version 24)
;; For important compatibility libraries like cl-lib
(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
const double eps = 1e-7 , pi = acos(-1.0);
inline int dcmp(double x) {
return (x > eps) - (x < -eps);
}
struct Point {