2010-01-01から1年間の記事一覧

2022 Princess, a Cryptanalyst

AOJ

概要 10個以下の長さ10以下の文字列が与えられるので、それらの全てを部分文字列に含む最も短い文字列を求める。 複数ある場合は辞書順最小のものを。 方針 すでに他の文字列の部分文字列になっているものは省いてから、つなぎ方を全探索する。 このとき、二…

2260 Error Correction

PKU

http://poj.org/problem?id=2260 概要 与えられた行列の各列各行の1の数が偶数であるか判定する。 偶数でない場合、ある一箇所を修正することで条件を満たすようにできるか調べる問題。 ソース #include<cstdio> #include<cstring> using namespace std; int main() { int n,a</cstring></cstdio>…

2263 Heavy Cargo

PKU

http://poj.org/problem?id=2263 概要 出発点から目的地までのパスの中で、パスの最小容量の辺の容量が最大になるようなパスを見つける問題。 ただ少し入力が面倒。 ソース #include<iostream> #include<cstring> #include<string> #include<map> using namespace std; #define REP(i,a,b) fo</map></string></cstring></iostream>…

これから

PKUやAOJで解いた問題やTopCoderやcodeforcesへの参加の記録をつけていこうと思います。

2258 The Settlers of Catan

PKU

http://poj.org/problem?id=2258 概要 グラフが与えられるので最も長いパスの長さを答える。 ソース #include<cstdio> #include<vector> #include<cstring> using namespace std; #define REP(i,a,b) for(i=a; i<b; ++i) #define rep(i,n) REP(i,0,n) int maxdepth; bool used[25][25]; void dfs(int depth,int p,vector<vector<int> > &g) { maxdepth = m…</b;></cstring></vector></cstdio>