Skip to content

Instantly share code, notes, and snippets.

View timshen91's full-sized avatar

Tim Shen timshen91

View GitHub Profile
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
using namespace std;
@timshen91
timshen91 / gist:4369263
Created December 24, 2012 13:30
Quick Hull Algo wish hand-craft HashTable.
// C++0x
#include <cstring>
#include <vector>
#include <string>
#include <climits>
using namespace std;
class pairSet {
const static unsigned int hSize = 100003;
package main
import (
"bufio"
"fmt"
"net"
"net/http"
)
type Reader struct {
@timshen91
timshen91 / enum.scm
Last active December 12, 2015 02:08
(enum '((1 2) (3 4) (5 6))) ; => ((1 3 5) (1 3 6) (1 4 5) (1 4 6) (2 3 5) (2 3 6) (2 4 5) (2 4 6))
(define (enum a)
(cond ((null? a) '(()))
(else (apply append (map (lambda (x) (map (lambda (y) (cons x y)) (enum (cdr a)))) (car a))))))
@timshen91
timshen91 / this.sh
Created February 7, 2013 09:34
./this.sh < $goagent/local/proxy.pac > out # "*" is reserved for matching any string. NO WARRANTY.
#!/bin/sh
sed 's|^.*if(\(.*\)/i\.test(url)) *return.*|\1|g' |
sed 's|^[^:]*:||' |
sed 's|\\\(.\)|\1|g' |
sed 's|\.\*|*|g' |
sed 's|^[^a-zA-Z0-9]*||'
@timshen91
timshen91 / main.cpp
Created March 15, 2013 12:09
OFF(噗...) model viewer based on OpenGL
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cassert>
#include <cmath>
#include <GL/gl.h>
#include <GL/glut.h>
#define sqr(a) ((a) * (a))
@timshen91
timshen91 / main.cpp
Created March 26, 2013 05:24
div without mul, div and mod
#include <cstdio>
int divImpl(int a, int b, int c, int * acc) {
if (a < b) {
return a;
}
int ret = divImpl(a, b + b, c + c, acc);
if (ret >= b) {
*acc += c;
ret -= b;
#include <cstdio>
#include <cstring>
#include <queue>
#define N 9
#define set1(a, b) a = ((a) | (1 << (b)))
#define set0(a, b) a = ((a) & (~(1 << (b))))
#define get(a, b) (((a) >> (b)) & 1)
#define fetch(a, b) ((((a) >> (2 * (b))) & 1) + (((a) >> (2 * (b))) & 2))
#define movable(p) ((((a[p]) >> 8) & 1) == 0)
#include <cstdio>
#include <cstring>
#include <vector>
typedef unsigned int st;
int n, m;
st a[1000];
st valid1[1030];
int validCnt[1030];
#include <cstdio>
#include <vector>
using namespace std;
int n;
vector<vector<pair<int, int> > > g;
vector<bool> vis;
int ans;
int cnt;