2010-03-01から1ヶ月間の記事一覧

SRM465 Div1 Easy(250), Div2 Medium(500) TurretPlacement

TurretPlacementある地点AとBに塔を作るとき、塔の大きさを最も大きくできるのは塔がAとBを結ぶ線分に平行な場合で、塔の大きさの和は最大でAとBの距離の倍。和がdになるような大きさの選び方はd(d-1)/2通り。 #include <vector> #include <cmath> using namespace std; cla</cmath></vector>…

SRM465 Div2 Easy(250) NumberNeighbours

NumberNeighbours #include <vector> #include <algorithm> using namespace std; class NumberNeighbours { public: int numPairs( vector <int> numbers ); }; int NumberNeighbours::numPairs( vector <int> numbers ) { int n = (int)numbers.size(); vector<vector<int> > normal( n ); for ( int</vector<int></int></int></algorithm></vector>…

SRM465

不参加。

SRM464 Div1 Medium(550) ColorfulDecoration

ColorfulDecoration二分探索。あるサイズの紙を重ならずに置けるかどうかはバックトラックで探索。 #include <vector> using namespace std; class ColorfulDecoration { struct POS { int x, y; POS(int x_, int y_) : x(x_), y(y_) {} bool operator==( const POS </vector>…

SRM464 Div2 Hard(1000) ColorfulMazeTwo

ColorfulMazeTwoまず、迷路中の全ての英字を'#'に置き換えて迷路を解く。解ければ安全に迷路を抜ける確率は1である。次に、迷路中の'A'を'.'にその他の英字を'#'に置き換えて迷路を解く。解ければ安全に迷路を抜ける確率は少なくとも1-trap[0]/100である。同…

SRM464 Div1 Easy(250), Div2 Medium(500) ColorfulStrings

ColorfulStrings全探索。n≦50とあるが各桁の数字は全て異なるのでcolorfulな文字列の個数はそれほど多くない。 #include <string> #include <set> using namespace std; class ColorfulStrings { string BT( int n, int k, string s, int *c ); bool check( string s ); p</set></string>…

SRM464 Div2 Easy(250) ColorfulBoxesAndBalls

ColorfulBoxesAndBalls #include <algorithm> using namespace std; class ColorfulBoxesAndBalls { public: int getMaximum( int numRed, int numBlue, int onlyRed, int onlyBlue, int bothColors ); }; int ColorfulBoxesAndBalls::getMaximum( int numRed, int numB</algorithm>…

SRM464

不参加。

SRM463 Div2 Easy(250) BunnyPuzzle

BunnyPuzzle #include <vector> using namespace std; class BunnyPuzzle { public: int theCount( vector <int> bunnies ); }; int BunnyPuzzle::theCount( vector <int> bunnies ) { int n = (int)bunnies.size(); int c = 0; for ( int i=0; i</int></int></vector>

SRM463 Div1 Easy(250), Div2 Medium(500) RabbitNumbering

RabbitNumbering例えば、ソートしたmaxNumberが{2,3,5,8}ならば、1番目の兎は2通り、2番目の兎は1番目の兎に付けた番号は使えないので3-1=2通り、3番目の兎は1,2番目の兎に付けた番号は使えないので5-2=3通りの選び方がある。 #include <vector> #include <algorithm> using nam</algorithm></vector>…

SRM463

Easy (250) 75.0long longで充分なのに多倍長が必要と思い込んで自前で実装、そして実装ミスって再提出。もったいない。Medium (500) 0解いている人はさっくり解いているけど、なんであの方法で良いのかわからない。Hard (1000) 0見てない。challenge +50Med…