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

Google Code Jam Round 1 A 2012

GCJ

結果から言うと20ptで死亡。 まずAに時間をかけすぎたのと、Bのデバッグが終わらなかった... 人権ない>

PKU3258 River Hopscotch

PKU

蟻本の練習問題。 岩の位置をソートして二分探索 #include <cstdio> #include <algorithm> using namespace std; int l, m, n; int rock[50000]; bool C(int d){ int last = 0; while(rock[last] < d){ last++; if(last == n) return false; } for(int i = 1; i < n - m; i++){ </algorithm></cstdio>…

AOJ0524 Searching Constellation

AOJ

あまり考えずに書いたので無駄なことしてる #include <cstdio> #include <vector> #include <algorithm> #include <map> using namespace std; int m, n, tmp; pair<int,int> ans; bool comp(const pair<int,int> a, const pair<int,int> b){ return a.first > b.first; } int main(){ while(scanf("%d", &m)){ if(m == 0</int,int></int,int></int,int></map></algorithm></vector></cstdio>…

AOJ0559 JOI Flag

bitDP初めてなのにこれをやったせいで苦戦しました. JOIの解説を読まないと解けませんでした...これだと解けるけどAOJではMLEします #include <cstdio> #include <cstring> using namespace std; const int mod = 100000; int n, m, count; char flag[21][21]; int fact[401];</cstring></cstdio>…

AOJVol5の残りのdp

http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0541 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0548 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0550 http://judge.u-aizu.ac.jp/onlinejudge/description.jsp…

AOJ0520 Lightest Mobile

明らかに二分木なのでメモ化再帰するだけ lcmを求めるところで先に2つをかけていたのでオーバーフローしてずっと悩んでました そこでみすってるとは... #include <cstdio> using namespace std; typedef struct stick{ int lren, rren, sl, sr, weight; } STICK; in</cstdio>…

Google Code Jam Qualification Round 2012

学校行って塾に行った後解くという過酷な感じになって辛かった A,B,Cを解いたけどCのlargeを落として45点だった・・・まあ進めたのでいいか() 60点は普通に取れた感じがします(D読んでないですすみません) A. Speaking in Tongues やるだけ 全単射だし変換法…

Volume5をうめたいなあ()

AOJ0532 説明略 #include <cstdio> using namespace std; int a, b, c, d, e, f, g, h, j; int main(){ for(int i = 0; i < 3; i++){ scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f); g = 3600 * (d - a) + 60 * (e - b) + (f - c); h = g / 3600; g %= 3600; </cstdio>…

AOJ0539 Pizza

なんかWAして悩んだけどよく考えたら確保した配列の要素が一個足りなかっただけだった(泣) 普通にやるとTLEするのでSをsortして配達先に最も近いSを2分探索で決めて足していくだけ #include <cstdio> #include <algorithm> #include <cmath> using namespace std; int d, n, m, ans, t</cmath></algorithm></cstdio>…

AOJ0529 Darts

JOI2007 本選の3番 蟻本のくじびきのやつみたいに2本ずつにわけて2分探索すれば間に合います #include <cstdio> #include <algorithm> #include <functional> using namespace std; int n, m, ans, fact; int k, lb, ub; int target[1000], tars[1002001]; void C(int p){ lb = 0, ub = fac</functional></algorithm></cstdio>…

AOJ0528 Common Sub-String

文字列をずらしてくらべて最大値更新していけば解ける #include <iostream> #include <string> #include <algorithm> using namespace std; int main(){ string a,b; int crtl,alen,blen,ans; while (cin >> a){ cin >> b; ans = 0; alen = a.size(); blen = b.size(); for(int i = 0; i <</algorithm></string></iostream>…