2011-07-01から1ヶ月間の記事一覧
TrainingCamp #include <string> #include <vector> using namespace std; class TrainingCamp{public: vector <string> determineSolvers( vector <string> attendance, vector <string> problemTopics ) { int N = (int)attendance.size(); int M = (int)attendance[0].size(); int K = (int)proble</string></string></string></vector></string>…
PerfectMemory残っているカード枚数と、そのうち一度もめくっていないカードの枚数ごとに、最小手数の期待値を覚えておいて、動的計画法。一度もめくっていないカードを最初にめくるのが最善で、1枚目が既にめくったシンボルの場合、2枚目はそのシンボルを…
YetAnotherIncredibleMachineそれぞれのplatformについて何通りの置き方があるか求めて、掛け合わせる。 #include <vector> #include <algorithm> using namespace std; class YetAnotherIncredibleMachine{public: int countWays( vector <int> platformMount, vector <int> platformLeng</int></int></algorithm></vector>…
Easy (250) 160.79 Medium (500) 0 Hard (1000) 0 Challenge 0 結果 1862 → 1792英語を読み間違ったのが痛い。時間があれば500も解けたかもしれないorz
CutTheNumbersメモ化探索。板のサイズが小さいので、板の切り取りかた全てについて、最大の和を覚えておくことができる。 #include <string> #include <vector> using namespace std; int memo[1<<16]; int bit( int x, int y ) { return 1<<(y*4+x); } int BT( vector<string> board</string></vector></string>…
TheAlmostLuckyNumbersDivOne16桁の全てのalmost lucky numberを生成して、a以上b以下かどうか調べる。1016はalmost luckyではない。 long long BT( int d, bool f, long long n, long long a, long long b ) { if ( d == 0 ) return a<=n && n<=b ? 1 : 0; …
IPv444それぞれの列について、一度も出てきていない数字の集合を-1で表す。出てきた数字と-1を組み合わせて得られる表現は、高々514個で、表すIPの個数が計算できて、同じ表現が分割されて売られることはない。各表現について、最高値を求める。 #include <string> #</string>…
GameOfLifeDivTwo #include <string> using namespace std; class GameOfLifeDivTwo{public: string theSimulation( string init, int T ) { int n = (int)init.size(); string C = init; for ( int i=0; i</string>
FiveHundredEleven現在のターン数とメモリの値でどちらが勝つかが決まる。なぜならば、メモリの寝ているビットのうち少なくとも1個が立っているカードは必ず残っているし、メモリの寝ているビットが全て寝ているカードは同一視できるから。ターン数とメモリ…
Zooウサギもネコもそれぞれ、0,1,2,…,n、0,1,2,…,mという答えになる。answersを2つに分けると、0≦i≦min(n,m)となるiに対しては選び方がそれぞれ2通り、min(n,m)<i≦(n,m)となるiがあるならばもう2通り。 #include <vector> using namespace std; class Zoo{public: l</vector>…
Easy (250) 191.56 (再提出) Medium (500) 199.13 Hard (1000) 0 Challenge 0 結果 1773→1862再提出をしても良いので、2問確実に解くことを目指したい。
忘れてた。