2010-07-01から1日間の記事一覧

SRM474 Div1 Easy(250), Div2 Medium(500) RouteIntersection

RouteIntersection頂点数が高々50なので、実際に動く次元の数も高々50。 #include <string> #include <vector> #include <map> #include <set> using namespace std; class RouteIntersection { public: string isValid( int N, vector <int> coords, string moves ); }; string RouteInters</int></set></map></vector></string>…

SRM474 Div2 Easy(250) PalindromesCount

PalindromesCount #include <string> using namespace std; class PalindromesCount { string reverse( string w ); public: int count( string A, string B ); }; string PalindromesCount::reverse( string w ) { string r; for ( int i=w.length()-1; i>=0; i-- )</string>…

SRM474

朝起きたら、すでに終わっていた。TCO中で通常のSRMが少ない上に寝坊で最近全然参加できていない。

SRM474 Div1 Medium(500) TreesCount

TreesCountダイクストラ法で頂点vの距離を確定するときに、確定済みの頂点からvへ向かう辺のうち1本を残し他を取り除くことを考える。uとvを結ぶ辺の長さをeとして、dist[u]+e=dist[v]となる辺から残す1本を選ぶ。 #include <string> #include <vector> using namespace st</vector></string>…

SRM474 Div2 Hard(1000) SquaresCovering

SquaresCovering動的計画法。2nの配列にビットが立っている点を覆う最小コストを格納。頂点を2つ選べば正方形の置き方が決まる。正方形を置く順番は任意なので、1つは最左の点を選ぶ。 #include <vector> using namespace std; class SquaresCovering { int countb</vector>…