TopCoder

SRM 641 div1

easy 頂点を4つの象限で分類して(軸は適当に含める)考えると、原点を内部に含む三角形は次の二つのうちいずれかを満たすことに気づく。 (1)頂点が向かい合う二つの象限(または軸の上)にある (2)頂点が三つの象限(または軸の上)にある(1)について、ある…

SRM 491 div 1

easy 和sとして、「和がsになる2つの数字の組合せ」を3つ取ってくる円順列を考えて、sがmax(7,K)から2N-5までの円順列の和を求めればよい。 #include <cstdio> #include <algorithm> #include <vector> #include <string> using namespace std; class FoxMakingDice{ public: long long c3(long </string></vector></algorithm></cstdio>…

SRM 595 div 1

1299 -> 1357 easyだけ解けたeasy 2^(最終的な色に関係ある区間の数)を計算すればいい #include <cstdio> #include <algorithm> #include <vector> #include <string> #include <queue> using namespace std; class LittleElephantAndIntervalsDiv1{ public: long long getNumber(int M, vector <int> L, vec</int></queue></string></vector></algorithm></cstdio>…

SRM 588 div 1

easy撃墜されて0pointだった 1225 -> 1194easy N=1のケースで撃墜されるコードを書いてしまった。 DP思いつかない人なので貪欲で解いた。 最大m個の歌を歌えるとして a1, a2, a3, ... , am の歌を歌うのにかかる時間Sは S = Σ(duration) + Σ(wait_time) = Σ(…

SRM 584 div 1

初めての div1 1217 -> 1225 easyだけ解いてなんとかレートを維持した。 いろいろライブラリをつくっていく必要がありそう。easy グラフの連結成分が2つ以上ある場合は無限に差を大きくできる。 連結成分が1つだけのときは2頂点間の最短経路のうち最長の長さ…

SRM 582 div 2

1116 -> 1217 青色になりました。 当面の目標は緑に下がらないこと。easy #include <cstdio> #include <string> using namespace std; class SemiPerfectSquare{ public: string check(int N){ bool f = 0; for(int a = 1; a <= N; a++){ for(int b = a + 1; a * b * b <= N;</string></cstdio>…

SRM 580 div2

1015 -> 1115 (+100) DIV1にあと2回ぐらいでなりたいeasy すべてのうさぎの組み合わせに対して、時間が重なっているかどうかをみるだけ #include <cstdio> #include <vector> #include <string> #include <algorithm> using namespace std; class ShoutterDiv2{ public: int count(vector <int> s, ve</int></algorithm></string></vector></cstdio>…

SRM 310 div1

easyだけ解いた 二分探索してレベルを決定して、コーナーケースに気をつけながら表面積を計算する。 コーナーケースありすぎorz #include <cstdio> #include <algorithm> #include <vector> #include <string> using namespace std; typedef long long ll; class PyramidOfCubes{ public: ll k; </string></vector></algorithm></cstdio>…

SRM 578 div2

917->1014 DIV2で59位でした。easy #include <cstdio> #include <algorithm> #include <vector> #include <string> using namespace std; class DeerInZooDivTwo{ public: vector <int> getminmax(int N, int K){ vector<int> ans; ans.push_back(max(0, N - K)); ans.push_back(N - (K + 1) / 2); return </int></int></string></vector></algorithm></cstdio>…

TCHS 10 Online Round 1

medの方がeasyより簡単だと思ったkに近い4の倍数と7の倍数は [k/4]*4 [k/4+1]*4 [k/7]*7 [k/7+1]*7 ([x]はガウスの記号(整数型の割り算)) のうちいずれか #include <cstdio> #include <vector> #include <algorithm> #include <cmath> using namespace std; class TheSequencesLevelOne{ public</cmath></algorithm></vector></cstdio>…

SRM450 div1 easy

ルールを変えたNimでAliceとBobのどちらが必勝かを判定する問題 ルール: 石が1個以上ある山がいくつかある。 プレイヤーは毎回、一つの山から石を1個以上とる。 山は順番に並んでおり、1個以上石が存在する山のうち一番左の山からしか石をとることはできな…

SRM 574 div2 (と科学の甲子園参加記)

第2回科学の甲子園に出場してきました。入賞できてよかった(小並感) 情報分野担当だったが、あまり力を出しきれなかった感があって残念。 実技3が事前公開だったはずなのに、自分たちのチームだけ知らなかった。そのプログラムを前日の夜に書いたが、バグ…

SRM 572 Div2

742 -> 933 (+191) 緑色になりました。 easyをdoubleで計算していた人がいて、1000000000を49個ぐらい並べてオバーフローさせた後で0を入れるとinf*0=nanみたいになる仕様を利用して撃墜しました。easy 0があるかないかと、負の数の個数を数える #include <cstdio> #</cstdio>…

SRM 561 div2

レート上がらない… easyしか分からなかった medは制約の読み間違えというクズいことをして、全探索するだけなのに気づかなかった。 気づけたとしても実装重めなので、できなかったかもしれない(小並感)250 #include <cstdio> #include <iostream> #include <cstring> #include <string> #inclu</string></cstring></iostream></cstdio>…

SRM 558 div2 600 解き直し

スタンプの長さのとりうる値の範囲は 0[i-l+1, i]をスタンプで色j(それより前は何の色でもよい)で塗る, という条件で 塗る方法の数 というDPを思いついた。 あとは漸化式たてて解いて、最小となるLを見つけて計算する。 O(N^4)ぐらいだと思う #include <cstdio> #inc</cstdio>…

SRM 559 div2

SRM 558 div2に参加しました easyは解けた med はDPで解けそうだなーと思いつつ実装間に合わなかった。 結果は 843 -> 879 (+36) 緑にあと2歩ぐらい届かず。 次こそ、緑になりたい。 #include <cstdio> #include <cstring> #include <string> #include <vector> #include <queue> #include <set> #include <algorithm></algorithm></set></queue></vector></string></cstring></cstdio>…

SRM 557 div2

SRM 557 div2に参加しました。 英語力がついていて、問題文をモリモリ読めた気がする。 あと、1つ撃墜できたのでよかった。 715 -> 843 (+128) はやく緑になりたい(小並感)easy250 #include <cstdio> #include <vector> #include <algorithm> using namespace std; class GreatFairyWar{</algorithm></vector></cstdio>…

SRM555

コンパイルエラーに悩んでいたらただ using namespace std; を書き忘れただけっていう。 早解きの練習が必要。 712 -> 715 (+3) #include <cstdio> #include <iostream> #include <algorithm> #include <vector> #include <string> using namespace std; class XorBoardDivTwo{ public: int theMax(vector <string></string></string></vector></algorithm></iostream></cstdio>…

SRM554

スーパーコンはレベル高すぎで、ついていけなかったです…。SRM554に参加しました 解法の勘違いしてEasyしか解けなくて人権ない #include <cstdio> #include <algorithm> using namespace std; class TheBrickTowerEasyDivTwo{ public: int find(int rC, int rH, int bC, int bH)</algorithm></cstdio>…

SRM540

div2 easy だけ解けた。 とても無駄のあるコード。setいらないと思う #include <cstdio> #include <algorithm> #include <set> using namespace std; typedef pair<int, int> P; typedef pair<int, P> RGB; typedef set<RGB> colors; class RandomColoringDiv2{ public: int D1, D2; int sR, sG, sB; colors </rgb></int,></int,></set></algorithm></cstdio>…