This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//source here | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <iostream> | |
#include <queue> | |
using namespace std; | |
const int N = 210; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
网络流 之 最大流 增广路算法 http://blog.163.com/art_budder_niu/blog/static/1393646202010322115138703/ | |
FF算法:分为三个步骤,首先寻找一条增广路(如果没有增广路,则返回最大流),同时保存路径;其次,对路径上的流量求最小值,记为min;最后根据路径修改网络,对于前向边,减去最小值,对于后向边,加上最小值,或者直接修改容量。 | |
增广路:从源点s到汇点t的一条有向路径,如果从源点开始不可以到汇点,那么没有增广路。 | |
保存:用一个数组保存,一般是采用父亲表示法(父链接),保存当前节点的父亲, 寻找的时候采用的是迭代的方式实现求最小值以及修改原网络。 | |
寻找增广路,采用bfs的方式。详细算法如下: | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma comment (linker, "/STACK:100000000") | |
#include <stdio.h> | |
#include <string> | |
#include <vector> | |
using namespace std; | |
#define N 101000 | |
char s[3*N]; | |
int p[3*N], l, r; | |
vector <int> m[N]; | |
string w[N]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#xinit appname -- :10 | |
# calculate first available VT | |
LVT=`fgconsole --next-available` | |
# calculate first usable display | |
XNUM="-1" | |
SOCK="something" | |
while [ ! -z "$SOCK" ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import msvcrt | |
import time | |
def raw_input_with_timeout(prompt, timeout=30.0): | |
finishat = time.time() + timeout | |
result = [] | |
while True: | |
if msvcrt.kbhit(): | |
result.append(msvcrt.getche()) | |
if result[-1] == '\r': # or \n, whatever Win returns;-) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, select | |
print "You have ten seconds to answer!" | |
i, o, e = select.select( [sys.stdin], [], [], 10 ) | |
if (i): | |
print "You said", sys.stdin.readline().strip() | |
else: | |
print "You said nothing!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Define a Timer context manager, allowing to measure the | |
wall time of the code block it contains. | |
Example: | |
>>> with Timer() as timer: | |
... for i in xrange(10000000): | |
... pass | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
what i did to add to get the files within a symlink into git (i didn't use a symlink but): | |
sudo mount --bind SOURCEDIRECTORY TARGETDIRECTORY | |
do this command in the git managed directory. TARGETDIRECTORY has to be created before the SOURCEDIRECTORY is mounted into it. | |
works fine! that trick helped me with subversion too. i use it to include files from an Dropbox account, where a webdesigner does his stuff. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding=utf-8 | |
''''' | |
socket 给百度发送http请求 | |
连接成功后,发送http的get请求,所搜索功能 | |
''' | |
import socket | |
import sys | |
import time |