2010-05-14から1日間の記事一覧

PKU 2560 Freckles

全域最小木 プリム法またはクラスカル法が使える typedef double Weight; struct Edge { int src, dst; Weight weight; Edge(int src, int dst, Weight weight) : src(src), dst(dst), weight(weight) { } }; bool operator < (const Edge &e, const Edge &f…

PKU 2263 Heavy Cargo

最短経路の応用 エッジを更新するときにそれまでの最大容量と道の容量の高い方を伝搬する 上はダイクストラ法、下はワーシャルフロイド法の解答 struct Dic { map<string, int> m; int get(const string& s) { map<string, int>::iterator it = m.find(s); if (it != m.end()) { return</string,></string,>…

PKU 1125 Stockbroker Grapevine

全点間最短距離 ダイクストラ法またはワーシャルフロイド法が使える static int g[128][128]; int main() { for (int N; cin >> N && N; ) { fill_n((int*)g, sizeof(g) / sizeof(g[0][0]), INT_MAX / 2); for (int n = 1; n <= N; ++n) { int M; cin >> M; …