実装問題

AOJ 0534 連鎖

以前、どうしてもバグが取れなくてあきらめていた問題 実装難しすぎ 解法 強実装。 #include <cstdio> #include <algorithm> using namespace std; const int MAX_N = 10000; int N; int main(){ while(scanf("%d", &N), N!=0){ int a[N]; for(int i = 0; i < N; i++) scanf("%d</algorithm></cstdio>…

AOJ 0536 Shuffle

問題 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0536解法 やるだけ問題なんだけど実装キツい カードの数字なんて気にしなくてよいので、最初に、r以下のカードを白い碁石、rよりおおきいカードを黒い碁石にでも置き換えると、ちょっと実装…

AOJ 0228 Seven Segments

明日テスト…… 簡単なやつをやったテーブルを作るだけの簡単なお仕事 #include <cstdio> using namespace std; const int d[11][7]={ {0,1,1,1,1,1,1}, {0,0,0,0,1,1,0}, {1,0,1,1,0,1,1}, {1,0,0,1,1,1,1}, {1,1,0,0,1,1,0}, {1,1,0,1,1,0,1}, {1,1,1,1,1,0,1}, {0,1</cstdio>…

AOJ 0569 Illumination

JOI予選のとき、問題文を読む前からあきらめてしまった問題。 今回やってみたら20分でできた。成長したなー。問題 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0569解法 六角形の移動先配列を持ちながら深さ優先探索 #include <cstdio> #include <algorithm> usi</algorithm></cstdio>…

POJ_2503 Babelfish

問題 辞書データとクエリが与えられるので、翻訳した結果を表示せよ。 辞書に載っていない場合"eh"と表示せよ 解法 辞書データはmapで管理した。 入力の処理に少し工夫が必要。 #include <cstdio> #include <cstring> #include <string> #include <map> #include <algorithm> using namespace std; typ</algorithm></map></string></cstring></cstdio>…

AOJ_0128 Abacus

問題 解法 テーブル作ってやるだけ。 #include <cstdio> using namespace std; const char table[10][9] = { "* = ****", "* =* ***", "* =** **", "* =*** *", "* =**** ", " *= ****", " *=* ***", " *=** **", " *=*** *", " *=**** ", }; int main(){ int n; boo</cstdio>…

AOJ_0105 Book Index

問題 解法 STLゲー。 map を使って単語と出現ページの情報を管理する。 #include <cstdio> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> #include <algorithm> using namespace std; typedef priority_queue<int, vector<int>, greater<int> > PAGE; typedef map<string, PAGE> INDEX; int main(){ char b…</string,></int></int,></algorithm></vector></string></queue></map></iostream></cstdio>

AOJ_0201 Wrought Gold Master

問題 解法 STLゲー。mapをアイテムの値段用とレシピ用に2つ使う。 再帰で最小の金額を求めていく。 #include <cstdio> #include <iostream> #include <map> #include <vector> #include <algorithm> using namespace std; typedef map<string, int> ITEM; typedef map<string, vector<string> > RECIPE; ITEM item; RECIPE recipe; int solve</string,></string,></algorithm></vector></map></iostream></cstdio>…

AOJ_0015 National Budget

あしたじゅけーーん 問題 解法 筆算するみたいにやっていけばいい。 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int MAX_K = 80; char num1[MAX_K + 1]; char num2[MAX_K + 1]; char numS[MAX_K + 1]; int k1, k2; bool plus(){ int t = 0, </algorithm></cstring></cstdio>…

AOJ_0130 Train

問題 解法 車両の移動を追っていって、今までにない車両の位置にきたら追加していけばいい。 #include <cstdio> #include <algorithm> #include <cstring> using namespace std; char str[1025]; char train[30]; int n; int main(){ char c; scanf("%d", &n); for(int i = 0; i < n; i++</cstring></algorithm></cstdio>…

AOJ_127 Pocket Pager Input

問題 解法 テーブルを作る。 数字を読んで変な数字がないか確認。 文字列出力。で解ける。 コード #include <cstdio> #include <cstring> #include <algorithm> using namespace std; char i2a[5][7] = { "afkpuz", "bglqv.", "chmrw?", "dinsx!", "ejoty " }; int main(){ char s[300]; </algorithm></cstring></cstdio>…

AOJ_0126 Puzzle

ものずごく実装問題。 さらに変な解き方をしたため、どこで何をしているコードなのか自分でも分からなくなった。 #include <cstdio> #include <algorithm> using namespace std; typedef pair<bool, int> P; int num[9][9]; //書いてある数字 int map[9][9]; bool b[9][9]; //書いてある数</bool,></algorithm></cstdio>…

AOJ_0100 Sale Result

解くためには、国語を勉強して作者の気持ちを読みとる能力をつける必要のある問題。 書かれるべき条件がいろいろと足りない。 #include <cstdio> #include <algorithm> using namespace std; const int MAX_N = 4000; long long p[MAX_N]; //売上金額 long long num[MAX_N]; //</algorithm></cstdio>…

POJ_1256 Anagram

勉強する気がおきない。問題 単語が与えられる。辞書式配列で、並び替えたものをすべて列挙せよ。 重複はだめ。 解法 やるだけ。 辞書の順序が AaBbCc...Zzとなっているのでこれに注意し、文字数値の変換用配列を作っておくと便利。 重複がダメなので、使っ…

AOJ_2102 ラミー

雪がかなり降っている。寒いいいい 実装がかなり難しかった。実装力ないのをどうにかしたい。 問題 略 解法 色ごとにカードをわけ、3枚ずつ選ぶ選び方をすべて試すというやり方をした。 カード1セットあたり最悪でも3*9C3*6C3=5040の計算しかしないので間に…

AOJ_0209 写真に写っている景色は?

問題 略解法 計算量はどんなに悪くても n^2 * m^2 * 4 = 10000 * 250 * 4 = 10000000 より少ないので、 全探索すれば大丈夫。正確な計算をすると、もっと小さくなる。回転させた図形の作り方 1、回転させる二次元配列(p[x][y])に、 (下から上に一列とりpn[x…

AOJ_2006 Keitai Message

問題 略解法 携帯電話のボタンごとの文字の割り当てを配列にしておくとやりやすい。実装 #include <cstdio> #include <cstring> using namespace std; char c[10][6] = { "", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz", }; int buf[1024]; void mes</cstring></cstdio>…