2011-03-31から1日間の記事一覧

方針がわからないときに見る記事

全探索、DP,貪欲、二分探索、数学

SRM431 div2 hard

全く歯が立たない。 探索だった。div2hardで初めて見た。 藪から棒だ。亀も木から落ちる。 #include <cmath> class SumAndProduct { public: int smallestSet(int S, int P) { if(S==P) return 1; double s=S,p=P; for(int n=2;n<=100;n++) if(p</cmath>

SCOTLAND YARD CONTEST

SCOTLAND YARD CONTEST というのが開催されるらしい。泥棒のAIならなんとかなる気がする。 1:まずmap[200][200]みたいな感じで警察からのコストを計算する 2:身近で一番コストの低いところに逃げる…テキトーだ

SRM424 div2 hard

最小全域木を求める。 存在しなかったら空のvectorを返す。 存在したら道の本数がMになるまで付け足す。 UNIONFINDのコードはコピーしたので集合のサイズを求める機能が付いてる。 #include <utility> #include <set> #include <vector> #include <algorithm> #include <string> using namespace std; </string></algorithm></vector></set></utility>…

gnuplot-4.4.3を使ってみた

こんなことができる。

SRM433 div2 hard

愚直にレシピをn^2回更新すればよい。 #include <iostream> #include <map> #include <sstream> #include <string> #include <vector> typedef long long LL; using namespace std; class MakingPotions { public: int getCost(vector <string> marketGoods, vector <int> cost, vector <string> recipes) { int n=recipes.</string></int></string></vector></string></sstream></map></iostream>…

gnuplot-4.4.3をインストールしてみた

使いもしないソフトをインストールする練習第n弾 INSTALLファイルに書いてあるけどubuntuの人は./configureする前に ln -s /usr/lib/pkgconfig/lua5.1.pc /usr/lib/pkgconfig/lua.pc を実行しないとmakeできない。 ほっといても害があるものなのかどうかは…

SRM428 div2 hard

nCrはパスカルの三角形で求められる。 あとオーバーフローするので C[i][j]=min(k+1,C[i-1][j]+C[i][j-1]); としなくてはならない。 #include <string> typedef long long LL; using namespace std; class TheDictionary { public: LL C[110][110]; string find(int </string>…