2012-02-01から1ヶ月間の記事一覧

SRM534 Div2 Easy(250) EllysDirectoryListing

EllysDirectoryListing #include <string> #include <vector> using namespace std; class EllysDirectoryListing{public: vector <string> getFiles( vector <string> files ) { int n = (int)files.size(); if ( files[n-2]=="." && files[n-1]==".." || files[n-1]=="." && files[n-2]==".</string></string></vector></string>…

SRM534 Div1 Medium(500) EllysNumbers

EllysNumbersn=xiyjzk… と表せるならば、有効な積の中で素因数xを含むspecialはちょうど1個。そこで、nを素数の冪の積に分解することを考える。例えば、n=360とすると、n=23*32*5 ではなく、n=8*9*5と分解する。こうすると、specialの要素の中から、素数の冪…

SRM534 Div1 Easy(250), Div2 Medium(500) EllysCheckers

EllysCheckers状態数が高々220通りなので、状態ごとに勝ち負けを覚えておいて、ゲーム木探索。もっと簡単に解ける。@nico_shindannin さんの放送で聞いた解法。チェッカーが盤上に残っているのにゲームが終わることはない。また、チェッカーは常に奇数マス右…

SRM534

Easy (250) 177.16 Medium (500) 0 Hard (1000) 0 Challenge 0 結果 319位 2078→2010

TopCoderプラグイン

最近は、http://d.hatena.ne.jp/kusano_prog/20091126/1259244682 とはちょっと違っているので....〆(・ω・` )メモメモCodeProcessor + TZTester 1.01 <cafelier&naoya_t>-custom + FileEditテンプレート // BEGIN CUT HERE #include <iostream> #include <sstream> #include <string> #include <vector> using namespac</vector></string></sstream></iostream></cafelier&naoya_t>…

SRM532 Div2 Easy(250) DengklekTryingToSleep

DengklekTryingToSleep #include <vector> #include <algorithm> using namespace std; class DengklekTryingToSleep{public: int minDucks( vector <int> ducks ) { return *max_element(ducks.begin(),ducks.end())-*min_element(ducks.begin(),ducks.end())-(int)ducks.size()+1; </int></algorithm></vector>…

SRM532 Div1(450) DengklekBuildingRoads

DengklekBuildingRoadsK≦8という制限がある。先頭の家から順に、自分より小さいに家との間にのみ道路を繋ぐとすると、直前K個の街の道路数の偶奇ごとに覚えておけば良い。道路を繋ぐ前のK個の家の道路の偶奇と、道路を繋いだ後の偶奇を決めると、それぞれの…

SRM532 Div1(300), Div2(600) DengklekMakingChains

DengklekMakingChains3個とも輪が綺麗な鎖を並べて左右に一番点数が高くなるように鎖を付けるか、1個の鎖の中央の輪だけを取るかのどちらかが最善。サンプルがしっかりしているかと思ったけど、まだ罠がある。例えば、{"1.1"}とか。 #include <string> #include <vector> #i</vector></string>…

SRM532

Easy (300) 235.31 Medium (450) 184.96 Hard (1000) 0 Challenge 0 結果 86位 2028→2078久々の2桁順位。

SRM531 Div2 Hard(950) KingdomReorganization

KingdomReorganization最小全域木。すでに存在する辺eを削除するのにコストCが掛かるというのは、辺の重みを-Cと考えて、あらかじめ重みの総和にCを加えておく。Prim法は重みが負でも動く。 #include <string> #include <vector> #include <queue> #include <utility> using namespace std; i</utility></queue></vector></string>…