Skip to content

Instantly share code, notes, and snippets.

@chiro
chiro / haskell
Created February 28, 2015 00:55
requests
POST / HTTP/1.1
Host: localhost:8000
Accept-Encoding: gzip
Content-Length: 3482
Content-Type: application/x-www-form-urlencoded
csrf_token=32bddc9d70f30f3441d01309c7117708&action=submitSolutionFormSubmitted&submittedProblemIndex=A&source=%23include%20%3Ciostream%3E%0D%0A%23include%20%3Cstring%3E%0D%0A%23include%20%3Cvector%3E%0D%0A%23include%20%3Cset%3E%0D%0A%23include%20%3Calgorithm%3E%0D%0Ausing%20namespace%20std%3B%0D%0A%0D%0A%2F%2F%20top%20bottom%20right%20left%20front%20back%0D%0A%0D%0Astring%20x%28string%20%26s%29%20%7B%0D%0A%20%20%20%20string%20ret%20%3D%20%22aaaaaa%22%3B%0D%0A%20%20%20%20ret%5B0%5D%20%3D%20s%5B4%5D%3B%0D%0A%20%20%20%20ret%5B1%5D%20%3D%20s%5B5%5D%3B%0D%0A%20%20%20%20ret%5B2%5D%20%3D%20s%5B2%5D%3B%0D%0A%20%20%20%20ret%5B3%5D%20%3D%20s%5B3%5D%3B%0D%0A%20%20%20%20ret%5B4%5D%20%3D%20s%5B1%5D%3B%0D%0A%20%20%20%20ret%5B5%5D%20%3D%20s%5B0%5D%3B%0D%0A%20%20%20%20return%20ret%3B%0D%0A%7D%0D%0A%0D%0Astring%20y%28string%20%26s%29%20%7B%0D%0A%20%20%20%20string%20ret%20%3D%20%22aaaaaa%22%3B%0D%0A%
'((1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1)
(1 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 1)
(1 3 1 1 1 2 1 1 1 2 1 2 1 1 1 2 1 1 1 3 1)
(1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1)
(1 2 1 1 1 2 1 1 1 2 1 2 1 1 1 2 1 1 1 2 1)
(1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1)
(1 2 1 1 1 2 1 2 1 1 1 1 1 2 1 2 1 1 1 2 1)
(1 2 1 1 1 2 1 2 2 2 1 2 2 2 1 2 1 1 1 2 1)
(1 2 2 2 2 2 1 1 1 2 1 2 1 1 1 2 2 2 2 2 1)
(1 1 1 1 1 2 1 0 0 0 0 0 0 0 1 2 1 1 1 1 1)
@chiro
chiro / gist:8fd1035c23e2a7c38188
Last active August 29, 2015 14:10
Taichung regional contest
G
H
J
N個の正実数 r_1, ..., r_N (0 < r_i < 1) が与えられる。
ここからk(>=2)個選び、選んだものを x_1, ..., x_k としたとき、
必ず x_1^s + ... + x_k^s = 1 となるようなsが存在し、
選び方が 2^N - N - 1 通りあるからこのようなsは2^N-N-1個存在する。
このようなsたち全てを葉においた2分木を作ったときに、その木の"secret number"を
#! /usr/bin/env python
# -*- coding:utf-8 -*-
import codecs
import csv
import urllib
import urllib.request
import urllib.parse
import os
import sys
/*
List Utility Code
*/
def arrayInit(n : Int, value : Int) : MyList[Int] = {
if (n == 0) {
return MyNil
}
return MyCons(value, arrayInit(n - 1, value))
}
@chiro
chiro / fib.gcc
Last active August 29, 2015 14:04
LDC 10 ; n
LDF 5
AP 1
DBUG
RTN
LD 0 0 ; entry point
LDC 1
CGT
SEL 10 22
RTN
@chiro
chiro / jmp.gcc
Last active August 29, 2015 14:04
;; LDC 0, LDC 0, CEQ, TSEL adr 0 でadrへの無条件jmpを表現できることを使って
;; 0+..+n をループで求める
;; environment frame の破壊的変更は ST でできる
LDC 0 ; sum
LDC 10 ; n
CONS
LDF 7
AP 1
DBUG
RTN
#include <chrono>
#include <iostream>
using namespace std;
int main() {
auto millis_since_epoch = chrono::duration_cast<chrono::milliseconds>(
chrono::system_clock::now().time_since_epoch()).count();
cout << millis_since_epoch << endl;
}
contest_list <- mapM (\entity -> do
let contest = Sq.entityVal entity
start_time <- showTime $ contestStart contest
end_time <- showTime $ contestEnd contest
return $ (getContestId entity, contestName contest,
contestJudgeType contest, start_time, end_time,
contestSetter contest)) contests
@chiro
chiro / r2a.py
Created October 22, 2013 06:16
Rime -> AtCoder.
#!/usr/bin/python
import sys, os, shutil
from os.path import *
command = "build"
dir_names = ["task", "in", "out", "sol", "etc"]
output_dir = join(abspath("./"), "atcoder", "Tasks")