Skip to content

Instantly share code, notes, and snippets.

#include "ford.h"
static const int32_t INF = 2147483647;
void ford(int32_t *d, size_t V, edge *es, size_t E, size_t s) {
for(int i = 0; i < V; i++)
d[i] = INF;
d[s] = 0;
while(true) {
bool update = false;
StageData = <<END
##########
#.dd..p..#
#........#
#.oo.....#
#........#
##########
END
class Tile
@rigibun
rigibun / bfr.rb
Last active August 29, 2015 13:59
require 'io/console'
memory = Array.new(30000, 0)
pointer = 0
director = 0
code = open(ARGV[0], "r").read
while director < code.size
char = code[director]
case char
when ">"
import std.stdio;
class C
{
this(string arg = "")
{
writeln("constructor is called." ~ arg);
}
~this()
import std.stdio, std.string, std.conv, std.algorithm;
void main()
{
while(true) {
auto input = readln.chomp.split(",");
int[] hand;
foreach(e; input)
hand ~= e.to!int;
if(!hand.length) break;
class List(T) {
public T head;
public List!(T) tail;
public this(T val) {
this.head = val;
this.tail = null;
}
public this(T[] arr) {
if(arr.length - 1 == 0){
import std.stdio, std.conv, std.string;
void main() {
int N = readln.chomp.to!int;
N.solve(0).writeln;
}
ulong solve(int n, int c) {
return n == 1 ? c : solve(n%2?n*3 + 1 : n/2, c+1);
}

C++初心者がC++を使って競技プログラミングするための備忘録のようなもの

この記事は、C++ (fork) Advent Calendar 2013の12日目の記事です。

はじめに

記事を書く人が居ないみたいなので、C++初心者ですが箸休め的な記事を書こうと思い立ち、いざ書き上げてみたら思いの外長くなりました。

この記事は、C++初心者な著者が、C++を用いて競技プログラミングをするために、調べたことや試した事などのまとめです。 記事中に誤り、問題点やご指摘、ご質問等ありましたら、@rigibunまでご連絡下さい(特にpush_bach)

githubのmarkdownを使いたかったことと、変更履歴が見られることからgistで書きました。

# dmd, libphobos and libgtkd2 were installed by apt-get with d-apt.
% ls
HelloWorld.d
% dmd HelloWorld.d -L-lgtkd2 -L-ldl
% ./HelloWorld
Fatal Error while loading '/usr/lib/x86_64-linux-gnu/libphobos2.so.0.64':
The module 'std.algorithm' is already defined in './HelloWorld'.
zsh: segmentation fault ./HelloWorld
@rigibun
rigibun / ski.py
Last active December 30, 2015 09:29
SKIコンビネータのような何か
def S(x):
return lambda y: lambda z: x(z)(y(z));
def K(x):
return lambda y: x;
def I(x):
return S(K)(K)(x);
def succ(x):