2011-01-28から1日間の記事一覧

SRM495 Div1 Easy(275), Div2 Medium(525) ColorfulCards

ColorfulCardsなるべく小さな数字を選んだとときと大きな数字を選んだときの数字が一致すればその数字、一致しなければ-1。 #include <string> #include <vector> using namespace std; class ColorfulCards{public: vector <int> theCards( int N, string colors ) { int n = (in</int></vector></string>…

SRM495 Div2 Easy(250) CarrotBoxesEasy

CarrotBoxesEasy #include <vector> #include <algorithm> using namespace std; class CarrotBoxesEasy{public: int theIndex( vector <int> carrots, int K ) { int m = 0; for ( int i=0; i</int></algorithm></vector>

SRM495 Div1 Medium(500) CarrotBoxes

CarrotBoxes強連結成分分解して、他から情報が得られない成分のみ開ければ良い。そのような成分の個数をxとすると成功する確率は(N-x)/N。ただし、最後に回すことで箱が1つだけ残るような成分があれば、その箱を開けずとも空と分かるので、確率は(N-x+1)/N…