Skip to content

Instantly share code, notes, and snippets.

"""
usage: cutter.py src destPrefix
"""
import sys, os
from time import sleep
CHUNK = 8 * 1024
BLOCK = 2 * 1024 ** 3 - 1
src = sys.argv[1]
destPrefix = sys.argv[2]
@ZhanruiLiang
ZhanruiLiang / fo.cpp
Created August 20, 2012 16:46
Data structure: Factor Oracle implement with c++
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<vector>
#include<cstring>
#include<algorithm>
#include<vector>
#define For(i, n) for(i = 0; i < n; i++)
@ZhanruiLiang
ZhanruiLiang / acauto_compact.cpp
Created August 20, 2012 16:56
AC automaton implement in C++
#include<iostream>
#include<sstream>
#include<string>
#include<queue>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<vector>
#include<cstring>
#include<algorithm>
@ZhanruiLiang
ZhanruiLiang / MyServer.java
Created October 9, 2012 04:28
Java Socket exp
import java.io.*;
import java.net.*;
import java.util.Scanner;
import java.util.NoSuchElementException;
public class MyServer{
ServerSocket serverSocket;
Socket clientSocket;
Scanner in;
BufferedWriter out;
@ZhanruiLiang
ZhanruiLiang / MyClient.java
Created October 9, 2012 04:33
Java Socket exp(Client)
import java.io.*;
import java.net.*;
import java.util.Scanner;
public class MyClient{
Socket clientSocket;
OutputStreamWriter out;
Scanner in;
public void connect(String dest, int port){
try{
@ZhanruiLiang
ZhanruiLiang / spfa.py
Created January 27, 2013 08:52
This gist test if SPFA can be performed with a stack. The result is, NO.
from collections import deque
import random
def gen_graph(n, m):
a = [[None] * n for i in range(n)]
for i in range(m):
x = random.randint(0, n-1)
y = random.randint(0, n-1)
c = random.randint(1, 100)
a[x][y] = c
return a
@ZhanruiLiang
ZhanruiLiang / quadtree.py
Created February 3, 2013 19:15
Quad tree implement using bin tree. Uses pygame to display.
#!/usr/bin/env python2
import pygame
from pygame.locals import *
COLOR_BG = (0xff, 0xff, 0xff, 0xff)
COLOR_BLACK = (0, 0, 0, 0xff)
COLOR_TRANS = (0, 0, 0, 0)
G = 1
class SMTNode:
@ZhanruiLiang
ZhanruiLiang / decovsmuli.py
Created February 4, 2013 08:30
Decorator Pattern vs. Multiple Inheritance.
#!/usr/bin/python2
class Window(object):
def draw(self, device):
device.append('flat window')
def info(self):
pass
# The subclass approch
class BorderedWindow(Window):
@ZhanruiLiang
ZhanruiLiang / brcki.py
Last active December 13, 2015 18:58
break out game. Written in python 3 with Pygame and PIL.
import pygame as pg
import bz2
import itertools
import Image
import ImageDraw
import pickle
from random import randint
from math import pi,sin,cos,sqrt,atan2
norm = lambda c:c/abs(c)
@ZhanruiLiang
ZhanruiLiang / SYSU-2013-05-04-board.txt
Last active December 17, 2015 00:09
中大ACM省赛前集训(5月4日)总board.
| Team| Solved| Penalty| A| B| C| D| E| F| G| H| I| J
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
> SYSU_TimeWizard| 7| 696| (4)| 1:27:23(1)| 2:37:22(1)| 0:42:34| | | 3:51:29(3)| 0:04:25| 0:24:06| 0:29:27(1) <
| sysu_stardust| 6| 700| | 3:04:55(4)| | 1:19:22| | | 4:20:29(1)| 0:07:49| 0:18:54(1)| 0:28:56 |
> MagnetWarrior| 6| 819| | 2:40:05| | 2:45:02(2)| | | 4:02:23(1)| 0:46:13| 0:54:45| 1:11:17(1) <
| sysu_3idiots| 5| 309| | (3)| | 1:00:11| | | 2:48:47(1)| 0:13:16| 0:19:30| 0:27:21 |
> DarkMagician|