Skip to content

Instantly share code, notes, and snippets.

View ftiasch's full-sized avatar

Xiaoxu Guo ftiasch

View GitHub Profile
@ftiasch
ftiasch / team.dot
Last active March 14, 2024 06:21
Member list of SJTU ACM (~ 2024)
// Contributor: gxx, mxh, lty, lmy, yzh
digraph {
// 2023
唐靖淇->李南锡
唐靖淇->谢尚航
唐靖淇->冯启豫 // replacement
杨宗翰->张建军
杨宗翰->张明驰
刘泳霖->戴之恒
刘泳霖->李青峰
@ftiasch
ftiasch / server.py
Created August 13, 2015 09:52
python SimpleHTTPServer with custom MIME types
import SimpleHTTPServer
import SocketServer
PORT = 8000
class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
pass
Handler.extensions_map['.shtml'] = 'text/html'
@ftiasch
ftiasch / kmp.hs
Created August 1, 2014 14:21
KMP Algorithm in haskell
data State = Null
| Node String State State
valid :: State -> Bool
valid state = case state of
Null -> undefined
Node string _ _ -> null string
match :: String -> String -> [Int]
match pattern = map fst . filter (valid . snd) . scanl step (0, root)
@ftiasch
ftiasch / test.rb
Created October 14, 2020 06:36
demonstrate the danger extending Ruby code objects with custom data members
class MyString < String
attr_reader :flag
def initialize(s, f)
super s
@flag = f
end
end
s1 = MyString.new ' misa', :misa
@ftiasch
ftiasch / pre-commit
Last active September 14, 2020 10:15
clang-format check git hook
#!/bin/bash
tmpfile=$(mktemp)
for f in `git diff --cached --name-only --diff-filter=ACMR | egrep '\.(cc|cu|cuh|h)$'`; do
git show :"$f" > $tmpfile
if ! diff -q "$tmpfile" <(clang-format "$tmpfile") 2>&1 >/dev/null; then
echo "$f" is not clang-formatted.
rm -rf $tmpfile
exit 1
fi
done
@ftiasch
ftiasch / sam.cpp
Created May 23, 2019 23:27
GP of Dolgoprudny Automaton
#include <bits/stdc++.h>
const int N = 40;
const int MOD = 1e9 + 7;
using Mask = uint64_t;
void update(int &x, int a) {
x += a;
@ftiasch
ftiasch / posts.markdown
Created September 27, 2014 02:40
Blog archive

{{{2013-03-16-sgu-321.markdown}}}

SGU 321 The Spy Network

Problem

$N$个点的有根树,边有黑白两色,将最少的黑边改成白边,使得从根到任意点的路径上,白边的数量不少于黑边。

($N \leq 200000$)

Solution

PublicTransitHard http://community.topcoder.com/stat?c=problem_statement&pm=13797
SimilarNames http://community.topcoder.com/stat?c=problem_statement&pm=12868
n个字符串s_1, s_2, …, s_n,m个条件(a_i, b_i),统计满足s_{p(a_i)}是s_{p(b_i)}前缀的排列p_1, p_2, …, p_n数量
n <= 50, |s_i| <= 50, m <= 8
BichromeSky http://community.topcoder.com/stat?c=problem_statement&pm=13711
n个红点,m个蓝点,没有三点共线,第i个红点以p_i的概率出现,求红点的凸包包含所有蓝点的概率
n, m <= 100
@ftiasch
ftiasch / BUCK
Last active December 17, 2018 07:50
buck issue report
prebuilt_cxx_library(
name = 'test',
exported_headers = ['test.h'],
shared_lib = 'libtest.so',
preferred_linkage = 'shared',
)
cxx_binary(
name = 'main',
srcs = ['main.cpp'],
@ftiasch
ftiasch / A.cpp
Last active July 28, 2016 13:15
2016 Multi-University Training Contest 4 team170
#include<stdio.h>
#include<stdlib.h>
#include<cstring>
#include<iostream>
#include<ctype.h>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>