Skip to content

Instantly share code, notes, and snippets.

View mrjohannchang's full-sized avatar

Johann Chang mrjohannchang

View GitHub Profile
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <pthread.h>
#include <assert.h>
#define CANDSIZE 1024
// #define BUFSIZE 8 * 1024 * 1024
@mrjohannchang
mrjohannchang / gist:3950140
Created October 25, 2012 02:36
Reverse the order of words in a sentence.
#include <stdio.h>
#include <string.h>
void reverse_char_array(char * first, char * last) {
while (first != last && first != --last) {
*first ^= *last;
*last ^= *first;
*first++ ^= *last;
}
}
void reverse_string(char * sentence) {
@mrjohannchang
mrjohannchang / gist:3813238
Created October 1, 2012 17:40
Codeforces 229A
n, m = map(int, raw_input().split())
table = [map(int, list(raw_input())) for _ in xrange(n)]
weighted_table = []
for r in table:
if sum(r) == 0:
print -1
exit()
weighted_row = []
for i in xrange(len(r)):
if r[i] == 1:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import Queue
import argparse
import os
import random
import subprocess
import sys
import threading
import time