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

SRM565 Div1 Medium(500) MonstersValley2

MonstersValley2全探索。 #include <vector> using namespace std; class MonstersValley2{public: int minimumPrice( vector <int> dread, vector <int> price ) { int n = (int)dread.size(); int ans = 2*n; for ( int i=0; i<1<</int></int></vector>

SRM565 Div2 Easy(250) ValueHistogram

ValueHistogram #include <string> #include <vector> #include <algorithm> using namespace std; class ValueHistogram{public: vector <string> build( vector <int> values ) { int hist[10] = {0}; for ( int i=0; i<(int)values.size(); i++ ) hist[values[i]]++; int H = *max_element(hist,hi</int></string></algorithm></vector></string>…

SRM565 Div1 Medium(500) TheDivisionGame

TheDivisionGame重複を許した素因数の個数がGrundy数となる。よって、P[i]をiの重複を許した素因数の個数として、Pの連続した部分列でxorした結果が0ではないものを数えれば良い。各iについてP[i]を求めると間に合わないが、各素数pについてpの整数倍のP[i]…

SRM565 Div1 Easy(250) MonstersValley

MonstersValley動的計画法。必要なコストごとに、最高のdreadを覚えておく。 #include <vector> #include <algorithm> using namespace std; class MonstersValley{public: int minimumPrice( vector<long long> dread, vector <int> price ) { int n = (int)dread.size(); vector<long long> T(2*n+1,-1); </long></int></long></algorithm></vector>…

SRM565

Easy (250) 218.80 Medium (500) 0 Hard (1000) 0 Challenge 0 結果 237位 2065→2047(´・ω・`)

SRM564 Div2 Hard(1050) KnightCircuit

KnightCircuit本番中には誰も解けなかった問題。要は、あるマスから到達可能な最大のマス数を返せば良い。盤面が小さいときと大きいときに分けて考える。盤面が小さいときは、実際に探索する。(0,0)から到達可能なマスに0を書き込み、0が書かれなかったマス…

SRM564 Div2 Medium(500) AlternateColors

AlternateColors1ステップずつ処理していては間に合わないので、まとめる。残りのボールの色数で関数を分けると、簡潔に書ける気がする。 #include <string> using namespace std; string solve2( long long c0, long long c1, long long k, string n0, string n1 ) </string>…

SRM564 Div2 Easy(250) FauxPalindromes

FauxPalindromesV.erase(unique(V.begin(),V.end()),V.end()) で連続している重複を削除できる。 #include <string> #include <algorithm> using namespace std; class FauxPalindromes{public: string classifyIt( string word ) { string r = word; reverse(r.begin(),r.end()</algorithm></string>…

SRM564 Div1 Medium(500) AlternateColors2

AlternateColors2素朴に求めるプログラムを書いて、その結果から一般項を推測した。n=kの場合はn個のボールを赤が最多となるように塗り分ける場合の数。kを固定した場合の答えは、階差数列が等差数列になっている。 long long naive( int n, int k ) { long …

SRM564 Div1 Easy'(250) KnightCircuit2

KnightCircuit2要は、あるマスから到達可能な最大のマス数を返せば良い。 class KnightCircuit2{public: int maxSize( int w, int h ) { if ( w==1 ) return 1; if ( w==2 ) return (h+1)/2; if ( h==1 ) return 1; if ( h==2 ) return (w+1)/2; if ( w==3 &…

SRM564

Easy (250) 197.02 Medium (500) 205.80 Hard (850) 0 Challenge 0 結果 182位 2067→2065

SRM563 Div2 Hard(1000) SpellCardsEasy

SpellCardsEasy動的計画法。位置pからl枚のカードを使いr枚のカードを残す場合の最高ダメージを覚えてく。O(n5)だけど、for(x=0;x #include <vector> using namespace std; class SpellCardsEasy{public: int maxDamage( vector <int> level, vector <int> damage ) { int n = </int></int></vector>…

SRM563 Div2 Medium(550) CoinsGameEasy

CoinsGameEasy全探索。 #include <string> #include <vector> using namespace std; vector<string> B; int w, h; int BT( int d, int cx1, int cy1, int cx2, int cy2 ) { bool in1 = 0<=cx1 && cx1</string></vector></string>

SRM563 Div2 Easy(250) FoxAndHandleEasy

FoxAndHandleEasy #include <string> using namespace std; class FoxAndHandleEasy{public: string isPossible( string S, string T ) { for ( int i=0; i<=(int)S.size(); i++ ) if ( S.substr(0,i)+S+S.substr(i)==T ) return "Yes"; return "No"; }};</string>

SRM563 Div1 Medium(500) SpellCards

SpellCards動的計画法。位置pからl枚のカードを使いr枚のカードを残す場合の最高ダメージを覚えてく。O(n5)だけど、for(x=0;x #include <vector> using namespace std; class SpellCards{public: int maxDamage( vector <int> level, vector <int> damage ) { int n = (int)lev</int></int></vector>…

SRM562 Div2 Medium(500) PastingPaintingDivTwo

PastingPaintingDivTwoある程度繰り返せば、ピクセル数の変化は一定になる。 #include <string> #include <vector> using namespace std; class PastingPaintingDivTwo{public: long long countColors( vector <string> clipboard, int T ) { int H = (int)clipboard.size(); int W =</string></vector></string>…

SRM562 Div2 Easy(250) CucumberMarket

CucumberMarket #include <vector> #include <algorithm> #include <numeric> #include <functional> using namespace std; class CucumberMarket{public: string check( vector <int> price, int budget, int k ) { sort(price.begin(),price.end(),greater<int>()); return accumulate(price.begin(),price.be</int></int></functional></numeric></algorithm></vector>…

SRM562 Div1 Medium(500) CheckerFreeness

CheckerFreenessわかんね(・3・) window.twttr = (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0], t = window.twttr || {}; if (d.getElementById(id)) return t; js = d.createElement(s); js.id = id; js.src = "https://platform.twi…

SRM563 Div1 Easy(250) FoxAndHandle

FoxAndHandleHの接頭辞を決めたとき条件を満たすかどうかは、SからHの文字をできるだけ左から選んでいき、各文字について選んだ個数と残りの部分の個数を合わせて、総数の半分に達するかどうかを調べればわかる。これを使って、Hを先頭から順に決めていく。 …

SRM563

Easy (300) 0 Medium (500) 226.22 Hard (950) 0 Challenge 0 結果 191位 2093→2067300はシステムテストで落ちた。きっちり証明できないけどたぶん合っているだろうというアルゴリズムは、たいてい間違えている(´・ω・`)

SRM562 Div2 Hard(900) RandomOption

RandomOptionレーンの組合わせと最右のレーンについて、苦手な組合わせを含まないレーンが何通りあるかを覚えれば、動的計画法で、苦手な組合わせを含まない全てのレーンの並べ方の総数が求められる。それをkeyCount!で割れば良い。 #include <vector> using namespa</vector>…

SRM562 Div1 Easy(250)

PastingPaintingDivOneある程度繰り返せば、ピクセル数の変化は一定になる。 #include <string> #include <vector> using namespace std; class PastingPaintingDivOne{public: vector<long long> countColors( vector <string> clipboard, int T ) { int H = (int)clipboard.size(); int W = (i</string></long></vector></string>…

SRM562

Easy (250) 213.67 Medium (500) 0 Hard (1000) 0 Challenge 0 結果 not rated500まで過去最高の出来 → 500再提出(´・ω・`) → システム500落ちる(´・ω・`) → 皆500落ちているし250が早かったので良い順位(`・ω・´) → not rated( ´ ・ ω ・ ` )