#include #include #include #include #define REP(i,n) for(int i=0;i<(int)n;++i) #define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i) #define ALL(c) (c).begin(), (c).end() using namespace std; typedef vector > Graph; void visit(const Graph &g, int v, vector< vector >& scc, stack &S, vector &inS, vector &low, vector &num, int& time) { low[v] = num[v] = ++time; S.push(v); inS[v] = true; FOR(e, g[v]) { int w = *e/*->dst*/; if (num[w] == 0) { visit(g, w, scc, S, inS, low, num, time); low[v] = min(low[v], low[w]); } else if (inS[w]) low[v] = min(low[v], num[w]); } if (low[v] == num[v]) { scc.push_back(vector()); while (1) { int w = S.top(); S.pop(); inS[w] = false; scc.back().push_back(w); if (v == w) break; } } } void stronglyConnectedComponents(const Graph& g, vector< vector >& scc) { const int n = g.size(); vector num(n), low(n); stack S; vector inS(n); int time = 0; REP(u, n) if (num[u] == 0) visit(g, u, scc, S, inS, low, num, time); } int main(){ int V; scanf("%d",&V); Graph g(V); vector L(V); vectorA(V); double R=0; for(int i=0;i > scc; stronglyConnectedComponents(g,scc); vectormn(scc.size()); fill(mn.begin(),mn.end(),1e9); vectorcom(V),deg(scc.size()); for(int i=0;i