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

SRM305 div2 hard

BFSだった、ミスらないようにゆっくり書いた 最悪の場合間に合わないけど、枝刈りがたくさん起こるので大丈夫 #include <algorithm> #include <queue> using namespace std; class QUE { public: int m,c,b,d; }; class Cannibals { public: int dist[100+10][100+10][2]; int </queue></algorithm>…

mozc使いたいけど、面倒くさいのはいや のっけからLinuxユーザーとしてはあるまじきタイトルだ ビルトしろよアホ、という声が動物園のペンギンの檻から聞こえてきそう

SRM351 div2 hard

答えみてしもうた。以下は解答の適当日本語訳。 1:選んでやつは消去できると考えられる 2:消去した残りがソートされてればよい 3:選ぶものの合計を最小化したい 4:残されるものの最大化 5:よって、最長増加部分列 #include <algorithm> #include <vector> using names</vector></algorithm>…

SRM302 div2 hard

div2hardの40問目。 メモ化再帰で解いた。ほとんど有り得ないけど、最悪O(100000*√100000)。 解説見るとBFS出来るらしい。値が減ることがないから。 #include <algorithm> using namespace std; int cache[100000+1]; class DivisorInc { public: int M; int rec(int nu</algorithm>…

東京バンドワゴンを読んでます。まだ評価はできないけどまあまあ面白いんじゃないかな

SRM388 div2 hard

数学。写した。 #include <vector> #include <algorithm> #include <list> using namespace std; class SmoothNumbersHard { public: int countSmoothNumbers(int n, int k) { vector<int> p(n+1,0); for(int i=2;i<=n;i++) if(!p[i]) for(int j=i;j<=n;j+=i) p[j]=i; int ans=0; for(int i</int></list></algorithm></vector>…

SRM356 div2 hard

ハイパー実装ゲー。解法は最小コスト木なのでプリム法。 #include <algorithm> #include <set> #include <string> #include <sstream> #include <queue> #include <vector> using namespace std; class UNIONFIND { public: vector<int> data; UNIONFIND(int size) { for(int i=0;i</int></vector></queue></sstream></string></set></algorithm>

SRM364 div2 hard

n #include <algorithm> #include <string> #include <vector> using namespace std; class PowerPlants { public: int n,aim; int cache[(1<<16)]; vector<string> cost; int popCount(int num) { int r=0; for(int i=0;i</string></vector></string></algorithm>

SRM383 div2 hard

行きと帰りでダイクストラして足すだけ、実装がエラいことになった #include <string> #include <vector> #include <queue> #include <algorithm> #include <cmath> using namespace std; class EDGE { public: int to,cost; bool operator <(const EDGE &e) const { return !(cost</cmath></algorithm></queue></vector></string>

SRM469 div2 hard

書くだけなんだけど、バグ連発で270点 #include <algorithm> #include <queue> #include <vector> using namespace std; class TheMoviesLevelThreeDivTwo { public: int n; vector<int> timeJ,timeB; queue<int> qJ,qB; bool check() { int tJ=0,tB=0; int wJ=0,wB=0; while(!qJ.empty() && !qB.</int></int></vector></queue></algorithm>…

SRM303 div2 hard

「やるだけ=バグ死」の敗北の方程式を何とかしたい …で、やるだけ。全探索で間に合う。 #include <string> #include <algorithm> #include <sstream> #include <vector> #include <iostream> using namespace std; class PrimePalindromic { public: int count(int A, int B) { int ans=0; for(int num=A;n</iostream></vector></sstream></algorithm></string>…

SRM348 div2 hard

メモ化再帰 "An increasing subsequence of a is maximal if unerasing any of the erased elements of a does not result in a longer increasing subsequence" ていうのは消したものを追加しても追加前より長い"increasing subsequence" になることはない…

SRM395 div2 hard

DP[何回目][ボーナスポイント]=得点でDP O(50^2)でちょっと変だと思ったけど送信した 英語を読み間違えた,"lose that many point"はpointを手に入れられないではなく pointが引かれる(-point)が足されるという意味 #include <cstring> #include <algorithm> #include <vector> using na</vector></algorithm></cstring>…

SRM378 div1 easy

asi1024さんが誘ってくれたのでやった 普通にやればいいんだけど、-1となるケースに注意(落とした) チャレンジやるとは思ってなかったのですぐsysytem testした asi1024さんすいません #include <algorithm> #include <vector> using namespace std; class TrueStatements { pu</vector></algorithm>…

SRM318 div2 hard

DPなんだけど、外した場合の事を考えてなくてエラいことになった DP[何回目][何点]=ここからwinする確立(パーセント) #include <algorithm> using namespace std; class SimplifiedDarts { public: double DP[1000+1][3000+1]; double tryToWin(int W, int N, int P1, </algorithm>…

SRM398 div2 hard

全探索。簡単だった。900で納得。 動かさないやつを決める #include <string> #include <vector> #include <iostream> #include <cstdio> using namespace std; class MatchString { public: int placeWords(string matchString, vector <string> matchWords) { int len=0; int n=matchWords.size(); fo</string></cstdio></iostream></vector></string>…

SRM323 div2 hard

全探索、AとBしか使わないんじゃねと思ったので思い切って書いてみたらあたった 怖かった 実際はもうちょっと文字を使う、ダメだ俺 #include <string> #include <vector> #include <cstring> #include <iostream> using namespace std; class UnrepeatableWords { public: int k,n,allowed; stri</iostream></cstring></vector></string>…

SRM328 div2 hard

DP苦手だからメモ化再帰 #include <map> #include <string> #include <sstream> #include <vector> #include <cstring> using namespace std; typedef pair<bool,vector<string> > KEY; class ScoreDifference { public: int board[4][4]; int cache[2][(1<<16)]; int ABS(int num) { return num<0 ? -num : num; } bool </bool,vector<string></cstring></vector></sstream></string></map>…

SRM357 div2 hard

ワーシャルフロイドではなかなか通らないので ダイクストラを使うべし(解説に書いてあった) ビット演算とかどんだけ #include <vector> #include <string> #include <cstring> #include <set> #include <sstream> #include <utility> using namespace std; typedef long long LL; class WebsiteRank { publi</utility></sstream></set></cstring></string></vector>…

SRM360 div2 hard

メモ化再帰ーDPの方がいいと思う #include <algorithm> #include <vector> #include <cstdio> #include <set> using namespace std; int result[2][1000000+10]; class TakeSubstringGame { public: vector<int> choice(int n) { vector<int> r; int num=n; while(num!=0) { int m=1; while(m<=num) { m</int></int></set></cstdio></vector></algorithm>…

SRM358 div2 hard

DPした、綺麗に書けた #include <algorithm> using namespace std; class SameDigits { public: int DP[2][1000+1]; int howMany(int n, int k) { for(int left=0;left<=n;left++) for(int used=0;used<2;used++) { DP[used][left]=0; if(used==1 && left==0) DP[used][</algorithm>…

JOI本選で大コケしました

1番でグローバル変数じゃないとMLEするのに気づけなかったのが主な敗因問1ーグローバル変数でとらないとMLE #include <string> #include <cstdio> #include <cstdlib> #include <vector> #include <iostream> #include <map> using namespace std; typedef long long LL; int memo[1000+1][1000+1][3]; int m</map></iostream></vector></cstdlib></cstdio></string>…