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

SRM556Div2

Medium: グラフと、各頂点の値が渡されるので、スタート地点からグラフを移動し、値をXORしていった時に得られる最大値を求める問題。 同じノードを複数回訪れる事も可能。無向グラフなら a->b->c->b->a という風に来た道を戻れば任意の値を使えるので、到達…

AOJ0176

AOJ

問題:What Color? 16進数で入力してやるだけ。 #include<iostream> #include<cstdio> #include<string> #include<map> #include<cmath> using namespace std; double d( int a, int b ) { double dr = (a&0xff0000) - (b&0xff0000); double dg = (a&0x00ff00) - (b&0x00ff00); double db = (a&0x000</cmath></map></string></cstdio></iostream>…

AOJ0122

AOJ

問題:Summer of Phyonkichi 時間差で動作するスプリンクラーの下をカエルのぴょん吉が渡る問題。 生死が掛かっているにも関わらず、ジャンプすることを強いられている。 #include<vector> #include<map> #include<iostream> #include<algorithm> using namespace std; #define debug(a) cout <<</algorithm></iostream></map></vector>…

AOJ0121

AOJ

問題:Seven Puzzle スライドパズルの最短スワップ回数を求める。 幅優先した。 #include<iostream> #include<vector> #include<map> #include<algorithm> #include<queue> #include<cstdio> using namespace std; #define rep(i,n) for( int i=0; i<n; ++i ) #define INF 1<<21 int main() { map< vector<int> , int > memo; vector<int> in(8); rep(i,8)…</int></n;></cstdio></queue></algorithm></map></vector></iostream>

AOJ0118

AOJ

問題:Property Distribution やるだけ問題。 再帰苦手なので再帰で書いた。 入力がw,hの順じゃなくてh,wの順でWAした。 #include<iostream> using namespace std; int dx[] = {0,0,1,-1}; int dy[] = {1,-1,0,0}; int dfs( char f[110][110] ,char c, int x , int y ) </iostream>…

AOJ0114

AOJ

問題:Electro-Fly mod取ってぐるぐる循環する奴が1周回るのにどれだけかかるかを求める問題。 愚直なループだとTLEするので、x,y,z別に求めてそれの最小公倍数で良い。 O(1)で求める解法ありそうだけどしらん。 #include<iostream> using namespace std; template<class t> t gc</class></iostream>…

AOJ0109

AOJ

問題:Smart Calculator 四則演算の計算機。 以前貼りつけた文字列を計算するやつが超絶バグっていてやばかった。 構文解析ってどうやってやるの?とかいいながら構文解析 Howto(もう答え)を参考にしながらポチポチした。ほぼ写経。 #include <iostream> #include <string> #in</string></iostream>…

SRM553Div2

Easy 全通り試す。TLEするかもしれないので一番内側にbreak仕込んどく。 class PlatypusDuckAndBeaver { public: int minimumAnimals(int WF, int DB, int BT) { REP(p,1001)REP(b,1001)REP(d,1001){ long long wf = 2*d + 4*b + 4*p; long long db = d + p;…

SRM554Div2

Easy 制約が小さいので全通り試す。 交互に置くので、タワーを建設できるかどうかは、使うブロックの数の差が1以下で判定。 テンプレが長くて減点をくらう。 #include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #i</iostream></set></utility></map></cfloat></climits></cmath></cstdlib></cstdio>…