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

方針がわからないときに見る記事

全探索、DP,貪欲、二分探索、数学

SRM431 div2 hard

全く歯が立たない。 探索だった。div2hardで初めて見た。 藪から棒だ。亀も木から落ちる。 #include <cmath> class SumAndProduct { public: int smallestSet(int S, int P) { if(S==P) return 1; double s=S,p=P; for(int n=2;n<=100;n++) if(p</cmath>

SCOTLAND YARD CONTEST

SCOTLAND YARD CONTEST というのが開催されるらしい。泥棒のAIならなんとかなる気がする。 1:まずmap[200][200]みたいな感じで警察からのコストを計算する 2:身近で一番コストの低いところに逃げる…テキトーだ

SRM424 div2 hard

最小全域木を求める。 存在しなかったら空のvectorを返す。 存在したら道の本数がMになるまで付け足す。 UNIONFINDのコードはコピーしたので集合のサイズを求める機能が付いてる。 #include <utility> #include <set> #include <vector> #include <algorithm> #include <string> using namespace std; </string></algorithm></vector></set></utility>…

gnuplot-4.4.3を使ってみた

こんなことができる。

SRM433 div2 hard

愚直にレシピをn^2回更新すればよい。 #include <iostream> #include <map> #include <sstream> #include <string> #include <vector> typedef long long LL; using namespace std; class MakingPotions { public: int getCost(vector <string> marketGoods, vector <int> cost, vector <string> recipes) { int n=recipes.</string></int></string></vector></string></sstream></map></iostream>…

gnuplot-4.4.3をインストールしてみた

使いもしないソフトをインストールする練習第n弾 INSTALLファイルに書いてあるけどubuntuの人は./configureする前に ln -s /usr/lib/pkgconfig/lua5.1.pc /usr/lib/pkgconfig/lua.pc を実行しないとmakeできない。 ほっといても害があるものなのかどうかは…

SRM428 div2 hard

nCrはパスカルの三角形で求められる。 あとオーバーフローするので C[i][j]=min(k+1,C[i-1][j]+C[i][j-1]); としなくてはならない。 #include <string> typedef long long LL; using namespace std; class TheDictionary { public: LL C[110][110]; string find(int </string>…

SRM501 div1 感想

#7零点

SRM372 div2 hard

501にボコボコにされて意気消沈してるから(読んでるひといないと思うけど) 解説はない ってうかディスプレイの文字が霞んで見えるんだよ。もうだめだよ。 conkyのuptimeが15時間超えてるよ。やばいよ。 #include <string> #include <queue> #include <vector> #include <utility> using n</utility></vector></queue></string>…

AOJ0047

#include <iostream> using namespace std; int main() { int cup[3]; cup[0]=1,cup[1]=0,cup[2]=0; string s; while(cin >> s) swap(cup[s[0]-'A'],cup[s[2]-'A']); if(cup[0]==1) cout << "A" << endl; if(cup[1]==1) cout << "B" << endl; if(cup[2]==1) cout << "C</iostream>…

SRM385 div2 hard

数学ゲーは嫌い。 また敗北した。 ”自然数a,b,mがあって、lcm(a,b) というのが "a,bが互いに素なら1=a*x+b*yとなるx,yが存在する" というのをもとにして成立する #include <cstdio> #include <algorithm> using namespace std; typedef long long LL; class SummingArithmeticPr</algorithm></cstdio>…

SRM448 div2 hard

メモ化再起。マークでは色なので気をつけてください。 #include <cstring> #include <string> #include <vector> #define MOD 1234567891 typedef long long LL; using namespace std; class TheCardLineDivTwo { public: int n; LL cache[13][2][(1<<16)]; vector<string> cards; char m2n(ch</string></vector></string></cstring>…

SRM355 div2 hard

自作クラスでsortとかを使う場合は bool operator<(const C &c) const{ return hoge; } ってしないとコンパイルできない #include <algorithm> #include <vector> using namespace std; class LIQUID { public: int p,a; bool operator<(const LIQUID &l) const{ return p<l.p; } }; class MixingLiquids { public: double howMuch(vector <int> perce</l.p;></vector></algorithm>…

SRM430 div2 hard

久しぶりにマイ・ドストライクコースことメモ化再起するだけの問題 #include <cstring> #include <string> #include <vector> using namespace std; class ImageTraders { public: int N; vector<string> price; int cache[20][20][(1<<15)]; int rec(int from,int nowPrice,int left) { int &</string></vector></string></cstring>…

xtwitterをインストールした

Xtwitter - cuspy wiki その 5 ソースからコンパイルに挑戦したんだけど失敗したので.debを使った

SRM373 div2 hard

殺す気か!めちゃめちゃしんどい。 線分の交差判定は検索して出てきた (x1-x2)*(y-y1)+(y1-y2)*(x1-x) これを使ったんだけど線分と長方形の辺が一致する場合のみ別に考える必要がある 参考にさせていただいたサイト: Algorithmの中の”第16回 もっと簡単に−…

conkyをインストールしてみた(ソースから)

2000 sudo apt-get update 2002 mkdir work 2004 cd work 2006 mv /home/hogeo/Downloads/conky-1.8.1.tar.bz2 . 2008 tar jxvf conky-1.8.1.tar.bz2 2010 cd conky-1.8.1/ 2016 sudo apt-get install libx11-dev 2023 sudo apt-get install lua5.1 2029 sud…

AOJ0117

ワーシャルフロイドするだけ。 scanf("%d,%d,%d,%d"......が便利だった #include <algorithm> #include <cstdio> using namespace std; int dist[20][20]; int main() { int n,m; scanf("%d%d",&n,&m); for(int i=0;i</cstdio></algorithm>

clive インストールしてみた

最新のバージョン(2.3)ではうまく動かなかったので 2.2でやったらうまいこと行った 実行したコマンドーー記録してませんでしたすいません tar zxvf clive-2.2.23.tar.gzしたらMakefile.PLのなかに必要なものが書いてあった アンインストールは/usr/l…

SRM382 div2 hard

難しかった。 まずある数列の (偶数番目の要素の和)=(奇数番目の要素の和)である集合をP (前半の和)=(後半の和)である集合をQとするDP[i][j]をi個の要素を持ち和がjである数列の数だとする(並び替えは違うものとする) するとn(P)+n(Q)はDPで求め…

AOJ0105

setとmap使えば自動的にソートしてくれるのでらくちん #include <iostream> #include <map> #include <set> #include <string> using namespace std; int main() { map<string,set<int> > index; string s; while(cin >> s) { int a; cin >> a; index[s].insert(a); } map<string,set<int> >::iterator mitr; for(mitr=ind</string,set<int></string,set<int></string></set></map></iostream>…

AOJ0107

解説のしようがない。消しゴムでも使って実験してみるといいのでは? #include <cmath> #include <cstdio> #include <iostream> using namespace std; void solve(int h,int w,int s) { int n; double r; r=sqrt(h*h+w*w); r=min(r,sqrt(h*h+s*s)); r=min(r,sqrt(w*w+s*s)); cin >> n; </iostream></cstdio></cmath>…

AOJ0112

引っ掛け問題。訴えてやる。(LLにしないと溢れます。) #include <iostream> #include <vector> #include <algorithm> typedef long long LL; using namespace std; void solve(int n) { LL r=0; vector<LL> v(n); for(int i=0;i<n;i++) cin >> v[i]; sort(v.begin(),v.end()); for(int i=1;i</n;i++)></ll></algorithm></vector></iostream>

SRM386 div2 hard

挫折。

SRM497 div2 hard

めっちゃ時間がかかったけど自分で解法を見つけた。 まずinsertは必要ない。(deleteで代用できる) 次にSを前半と後半に分け(最大50通り)その2つを等しくするための最小値を 求める。 先頭同士が同じならその先頭は無視して次を考える if(s[i]==t[j]) D…

SRM496 div2 hard

文字列は生成しない方向で頑張っていたんだけど無理だった。 まあ理解はした。

SRM500 div1 easy

まずソートして1番票をもらう人をもとめる。(ソースではNmost人としている) それから"vulnerable"な人の人数が一人になるか変わらなくなるまで シュミレーションする。 #include <algorithm> #include <vector> using namespace std; class MafiaGame { public: double probabi</vector></algorithm>…

SRM500 div1 感想

easyだけ通して100.46点。1395から1519。

SRM416 div2 hard

十八番のメモ化再帰。 #include <algorithm> #include <cstring> #include <string> #include <vector> using namespace std; class DancingCouples { public: vector <string> can; int bn,gn; int cache[11][11][(1<<10)]; int rec(int b,int K,int left) { int &r=cache[b][K][left]; if(r!=-1) return</string></vector></string></cstring></algorithm>…