SRM 551 450pt : ColorfulWolves
問題概要
最短路を求める問題。200でよいと思う。
struct ColorfulWolves { int getmin(vector <string> colormap) { const int n = colormap.size(); G.init(n); for (int i = 0; i < n; ++i) { int count = 0; for (int j = 0; j < n; ++j) { if (colormap[i][j] == 'Y') { G.addDirectedEdge(i, j, count); ++count; } } } int ans = calcSingleSourceShortestPath(G, 0, n - 1); return ans == INF ? -1 : ans; } };