utsubo’s blog

競技プログラミングとか.

2015-03-01から1ヶ月間の記事一覧

SRM654 Div2 Med / OneEntrance

問題 http://community.topcoder.com/stat?c=problem_statement&pm=13698 真姫の新しい家に家具をN個設置したい。部屋の隣接関係と入り口の部屋の番号が与えられ、部屋の隣接関係は木構造をしている。N個の家具を順番に部屋に設置していくが、家具を設置した…

SRM654 Div2 Easy / SquareScoresDiv2

問題 http://community.topcoder.com/stat?c=problem_statement&pm=13700 ある文字列の部分文字列の中で同じ文字が連続しているものをカウントする。 解法 全探索 class SquareScoresDiv2 { public: int getscore(string s) { int ret = 0; for(int i=0;i

SRM654 Div2 Hard / SuccessiveSubtraction2

問題 http://community.topcoder.com/stat?c=problem_statement&pm=13699 配列aが与えられ、それはa[0]-a[1]-...-a[n]という式を表す。この式の中に括弧を2組まで入れた時式の結果の最大値答える。 解法 Editorial一部改変。 http://apps.topcoder.com/wiki/…

yukicoder No.60 魔法少女

問題 No.60 魔法少女 - yukicoder 感想 二次元imos法で各座標に加わるダメージを計算する。 いもす法 - いもす研 (imos laboratory) #include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = 1e9; const int MOD = 1e9+7; int main(void) { i</bits/stdc++.h>…

AtCoder Beginner Contest #008 D- 金塊ゲーム

問題 D: 金塊ゲーム - AtCoder Beginner Contest #008 | AtCoder 感想 AtCoder Beginner Contest 008 解説 解説スライドを見ながら解きました。 #include <bits/stdc++.h> using namespace std; int w,h; vector<int> x,y; map<tuple<int,int,int,int>,int> memo; int dfs(int l,int r,int u,int d){ int</tuple<int,int,int,int></int></bits/stdc++.h>…

yukicoder No.164 ちっちゃくないよ!!

問題 No.164 ちっちゃくないよ!! - yukicoder 感想 それぞれ、(含まれている数字の最大値+1)進数で最小。 str.to_i(n)で文字列をn進数にできてruby凄い。 n = gets.to_i a = [] for i in 1..n a.push(gets.to_s) end t = 0 dic = {} for s in "0123456789A…

yukicoder No.163 cAPSlOCK

問題 文字列の小文字は大文字に大文字は小文字にする。 感想 それぞれのxor 32をとると大文字・小文字が反対になる。 #include <bits/stdc++.h> using namespace std; int main(void) { string s; cin >> s; for(int i=0;i</bits/stdc++.h>

yukicoder No.67 よくある棒を切る問題(1)

問題 http://yukicoder.me/problems/145 感想 長さを二分探索したけど、で回すと大きい数の時、無限ループしてしまいました。 なので適当に100回ぐらいで打ち切った。 #include <bits/stdc++.h> using namespace std; typedef pair<int,int> P; typedef pair<int,pair<int,int>> PP; typedef long long </int,pair<int,int></int,int></bits/stdc++.h>…

yukicoder No.27 板の準備

問題 http://yukicoder.me/problems/32 感想 制約が小さいので全探索できそう。 A,B,Cのそれぞれの長さ、それぞれの使う枚数について回して30^6ぐらいだけど実際はもう少し小さいから間に合った。 #include <bits/stdc++.h> using namespace std; typedef pair<int,int> P; typedef p</int,int></bits/stdc++.h>…

Codeforces #294(Div.2)

1575->1516(-59) レートは下がっちゃったけど人が多いのは楽しいですね。 A,B:手間取った。 C:よくわからないので二分探索しようとしたけど、二分探索が書けなくて焦った。 D:累積和してどうするんだろう・・・ E:読めてない 二分探索きっちり書くの難しい。…