AOJ

HaskellからAOJにサブミットする

http-enumerator使って書いた。 大したコードじゃないので、ここに貼っておくことにする。 twitter-enumeratorのコードを参考にした。 気が向いたら、公開されているAPIのためのコードも書いてまとめるかもしれない {-# LANGUAGE OverloadedStrings #-} impo…

1163 Cards

AOJ

http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=1163 方針 明らかに2部グラフのマッチングに見える。 ソース

1296 Repeated Substitution with Sed

AOJ

http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=1296 方針 置換えを実行すると必ず文字数が増えるという条件と、 targetとなる文字列の長さが10以下という条件から、置き換えは最大9回しか起こらないということが分かるので、BFSする。…

1304 Infected Land

AOJ

http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=1304 方針 広さが5*5しかないので、BFSした。 ソース

2211 迷い猫、走った

AOJ

http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=2211&lang=jp 方針 最大値を最小化する問題なので、2分探索すればいいのはすぐにわかる。 けれども、ある猫の数以下で条件を満たすことができるかどうかの判定が難しい。 解説のスライ…

AOJ 2103 Battle town

AOJ

http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=2103 方針 書かれている通りに頑張って実装する。 ソース

2208 トーマス・ライトの憂鬱

AOJ

http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=2208&lang=jp 方針 決められるところから全部決めていってしまう。 全部決められなければ、解はない。 ソース

1168 ぐらぐら

AOJ

ほうしん まず番号がかぶっているブロックがあるので、番号を振り直す。 そのときついでに、自分の上に乗っているブロックと自分が他のブロックまたは地面と接している部分を求めておく。 一番下の地面に接しているブロックから順に、自分と自分の上に乗って…

1140 Cleaning Robot

AOJ

http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=1140&lang=jp ほうしん 幅優先探索で、各汚れたタイルと初期位置との距離を全て求めておきTSPにして解く。 ソース #include<iostream> #include<string> #include<cstring> #include<queue> #include<vector> #include<algorithm> using names</algorithm></vector></queue></cstring></string></iostream>…

1126 The Secret Number

AOJ

http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=1126 方針 ある位置までの可能な最大値でDPする。 ソース #include<iostream> #include<string> using namespace std; #define REP(i,a,b) for(int i=a; i</string></iostream>

1014 Computation of Minimum Length of Pipeline

AOJ

http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=1014 概要 温泉とそれぞれの地区の距離が与えられるので、すべての地区に温泉がいきわたるための 最小のパイプの長さを求める。 方針 はじめにヒープに温泉から出ている辺をすべて追加…

1032 Course Planning for Lazy Students

AOJ

http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=1032&lang=jp 概要 最低限の単位数を確保する最小の講義数を求める問題。 ある講義に対して、あらかじめとっておかないといけない講義がある場合がある。 ほうしん うまいやり方が思い…

0527 Setting Go Stones

AOJ

http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=0527 方針 同じ色の碁石が連続する部分を、部分の始まり、部分の終わり、色を要素にもつ構造体で表した。 ソース #include<vector> #include<iostream> using namespace std; #define REP(i,a,b) for(i=a;</iostream></vector>…

0525 Osenbei

AOJ

http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=0525 方針 行数が最大10行までと小さいので、行のひっくり返し方を決めて全探索する。 行のひっくり返し方が決まれば、列の最適なひっくり返し方は一意に決まる。 ソース #include<cstdio> #inc</cstdio>…

0520 Lightest Mobile

AOJ

http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=0520 方針 dfsして、先端の方から順番に重さを決める。 ソース #include<iostream> #include<vector> using namespace std; #define REP(i,a,b) for(i=a; i</vector></iostream>

2022 Princess, a Cryptanalyst

AOJ

概要 10個以下の長さ10以下の文字列が与えられるので、それらの全てを部分文字列に含む最も短い文字列を求める。 複数ある場合は辞書順最小のものを。 方針 すでに他の文字列の部分文字列になっているものは省いてから、つなぎ方を全探索する。 このとき、二…