2011-04-02から1日間の記事一覧

1126-The Secret Number

AOJ

問題概要 WxHの数値や文字のかかれたマス目が与えられる。 このマス目を下または右に移動して作り出せる数のうち最大の物を求めよ考え方 最大70文字の長さになるのでlong longでもオーバーフローするので文字列を用いる。 後は座標(x,y)から作り出せる最大の…

1125-Get Many Persimmon Trees

AOJ

問題概要 WxHのマス目があり、そのうちN個が埋まっている。 そのN個の座標x,y(1 SxTの大きさのマスに入る最大の埋まっているマスの個数を答えよ。 考え方 考えられる場所全てを調べる。実装(C++) #include <iostream> #include <cstring> using namespace std; char MAP[100][10</cstring></iostream>…

1124-When Can We Meet?

AOJ

http://rose.u-aizu.ac.jp/onlinejudge/ProblemSet/description.jsp?id=1124 問題概要 会社で会議を開きたい。 社員の人数N、議決に必要な人数Qと社員にとって都合の良い日が与えられる。 最も都合の良い社員が多くて、早い日を答えよ。 正し議決に必要な人…

1145-The Genome Database of All Space Life

AOJ

考え方 一文字ずつ読み進めていく。 ループがある場合は同じ文字を指定回数だけ読み進めれば良い。実装(C++) #include <iostream> using namespace std; int cnt=0; int tar; char ans; bool solve(string in){ string res; int L=in.size(); int i=0; while(i<L){ if(in[i]>='A'&&in</l){></iostream>…

1144-Curling 2.0

AOJ

考え方 深さ優先探索する。 実装(C++) #include <iostream> #include <algorithm> #include <cstring> using namespace std; int W,H,gx,gy; int ans; int MAP[22][22]; int dx[4]={0,1,0,-1}; int dy[4]={1,0,-1,0}; void dfs(int cnt,int x,int y){ if(x==gx&&y==gy){ ans=min(ans,cnt); </cstring></algorithm></iostream>…

1142-Organize Your Train part II

AOJ

考え方 全ての並べ方を列挙してみる。 実装(C++) #include <cstdio> #include <cmath> #include <cstring> #include <cstdlib> #include <climits> #include <cctype> #include <ctime> #include <cassert> #include <cwchar> #include <cstdarg> #include <cwctype> #include <queue> #include <stack> #include <algorithm> #include <list> …</list></algorithm></stack></queue></cwctype></cstdarg></cwchar></cassert></ctime></cctype></climits></cstdlib></cstring></cmath></cstdio>

1141-Dirichlet's Theorem on Arithmetic Progressions

AOJ

考え方 実装するだけ 実装(C++) #include <cstdio> #include <cmath> #include <cstring> #include <cstdlib> #include <climits> #include <cctype> #include <ctime> #include <cassert> #include <cwchar> #include <cstdarg> #include <cwctype> #include <queue> #include <stack> #include <algorithm> #include <list> #include…</list></algorithm></stack></queue></cwctype></cstdarg></cwchar></cassert></ctime></cctype></climits></cstdlib></cstring></cmath></cstdio>

1114-Get a Rectangular Field

AOJ

問題概要 5x5のマス目の情報が与えられる。 中に入る最大の長方形の面積を求めよ。考え方 ヒストグラムの最大長方形だと見なすことで 蟻本p280の考え方が利用出来る。 ただ、5x5なので普通に全探索しても良いかも。 実装(C++) #include <iostream> using namespace std</iostream>…