Skip to content

Instantly share code, notes, and snippets.

View ftiasch's full-sized avatar

Xiaoxu Guo ftiasch

View GitHub Profile
@ftiasch
ftiasch / Min.hs
Created January 5, 2015 14:04
Min mod
import Control.Monad
import Control.Monad.State.Lazy
import Data.ByteString.Lazy.Char8 (ByteString)
import qualified Data.ByteString.Lazy.Char8 as BS
import Data.Char
import Data.List
import Data.Maybe
data Operation = Update { index :: Int, multiple :: Int }
@ftiasch
ftiasch / main.coffee
Created September 30, 2014 04:13
WebQQ robot
crypto = require 'crypto'
request = require 'request'
cookieJar = request.jar()
request = request.defaults {jar: cookieJar}
#require('request').debug = true
class Client
constructor: (@id, @password) ->
@ftiasch
ftiasch / chat.txt
Last active July 24, 2016 02:23
天国的浣熊群水群精华
POJ3222.txt
misaka.99999: 11:20:53
题目等价于给边定向,使得每个点的度都是偶数。既然如此,如果一个连通分量有奇数条边,那么总点度 = 边数 = 奇数,就无解。否则,求出连通分量的一颗生成树,对于非树边随意定向。现在相当于要给树边定向,使得点度是奇数(或偶数,取决于非树边随意定向的结果)。在生成树上dfs构造,对于每个点u,考虑它父亲p到它的边(p, u),根据下面定向的结果,我总能定向(p, u)使得点u满足。只剩下根,因为总点度是个偶数,所以根是天然满足的。证毕。
SPOJ_PGCD.txt
: 08:51:10
问一下spoj4491的miu函数到底怎么构造?
: 08:56:25
4491是什么?
: 08:56:37
@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

@ftiasch
ftiasch / solution.cpp
Last active September 9, 2015 14:16
2014 Beijing Regional Onsite Contest Problem J Just a Challenge
/*
* 假设l = aa..a, r = bb..b,则题目等价于计算树上距离恰好是m的点对数量。不难发现本题需要树分治,
*
* 分治点u时,假设v到u对应的字符串是S = s1 s2 ... sk,需要比较S和l, r长度为k的前后缀的字典序大小。
*
* (作减法之后,只讨论上界r)
* 1. 对reverse(r)建立后缀自动机。
* 从u开始dfs树,在自动机上对应转移。
* 因为所在节点的right集合不一定包含前缀0,
* 所以需要预处理节点(沿着parent)最近的包含前缀0的祖先,
@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 / executor.cpp
Last active August 29, 2015 14:05
Executor.cpp
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <errno.h>
#include <pwd.h>
#include <unistd.h>
#include <sys/resource.h>
@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 / Makefile
Created May 15, 2014 02:07
Reliable Transport Protocol
CCFLAGS=-w
main: main.c
${CC} ${CCFLAGS} main.c -o main
@ftiasch
ftiasch / Brute.java
Last active August 29, 2015 13:58
GD vs ZJ Problem E
import java.io.*;
import java.math.*;
import java.util.*;
public class Brute {
public void run() {
try {
int testCount = reader.nextInt();
for (int t = 1; t <= testCount; ++ t) {
int n = reader.nextInt();