いろいろがんばりたいブログ

情報科学科の人がいろいろ書きます。

2013-10-01から1ヶ月間の記事一覧

POJ 1637 Sightseeing tour

オイラー閉路にtwo-wayなエッジを追加した問題. 最大流で解けます。考え方は以下の通り まずtwo-wayなエッジであろうと入力そのまま有向なエッジとしてグラフに追加していく。 出るエッジについて-1,入るエッジについて+1を各ノードで計算しておく。通常のオ…

EmacsでシンタックスハイライトしたテキストをHTML化する方法

Emacs24以上で。 package.elとかでhtmlizeをインストールする。 disable-themeでテーマを一時的に無効化(黒背景とかだとヤバい?) M-x htmlize-file でファイルを指定する。 HTMLができる 参考 http://yohshiy.blog.fc2.com/blog-entry-8.html http://www.em…

StateMonadをOCamlで書いた。

というお話。コンパイラを書く時に必要になるっぽいので。 (*simple monad*) module type MONAD = sig (* Type for state.It's Covariant*) type +'a t (* lift up normal value to monaded value.*) val return : 'a -> 'a t (* bind is the function to ap…

3次元ヤング図形を列挙するアルゴリズムについて

工大祭で出してみたので. 簡単な再帰でかけました。 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include

Generating Polynomino in C++

http://en.wikipedia.org/wiki/Polyomino one-handedなもの。つまり回転による同型は無視する。また、穴があるものはなしとする。 #include <iostream> #include <iomanip> #include <vector> #include <map> #include <set> #include <queue> #include <bitset> #include <stack> #include <utility> #include <numeric> #include <algorithm> #includ</algorithm></numeric></utility></stack></bitset></queue></set></map></vector></iomanip></iostream>…

Topcoder SRM 593 div1

本番中は250のみを通した。 250 四色定理より、明らかに4以下であることはわかる。 しかし、すこし考えると、3色で塗り分け可能であることがわかる。 なので、0,1,2で塗れるかどうかを考えるだけで良い。 2色で塗れるかは再帰的にDFSをすればよい。(蟻本参照…