Topic Link:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&itemid=8&page=show_problem& problem=737
Find the number of bridges, that is, the number of cutting edges. Input a little pit, left and right brackets must have a space before the line, initially thought to be an escape problem.
1 /*2 ━━━━━┒ギリギリ♂eye! 3 ┓┏┓┏┓┃キリキリ♂mind! 4 ┛┗┛┗┛┃\0/5 ┓┏┓┏┓┃/6 ┛┗┛┗┛┃ノ)7 ┓┏┓┏┓┃8 ┛┗┛┗┛┃9 ┓┏┓┏┓┃Ten ┛┗┛┗┛┃ One ┓┏┓┏┓┃ A ┛┗┛┗┛┃ - ┓┏┓┏┓┃ - ┃┃┃┃┃┃ the ┻┻┻┻┻┻ - */ -#include <algorithm> -#include <iostream> +#include <iomanip> -#include <cstring> +#include <climits> A#include <complex> at#include <fstream> -#include <cassert> -#include <cstdio> -#include <bitset> -#include <vector> -#include <deque> in#include <queue> -#include <stack> to#include <ctime> +#include <Set> -#include <map> the#include <cmath> * $ using namespacestd;Panax Notoginseng - #defineFr First the #defineSC Second + #defineCL Clear A #defineBUG puts ("Here!!!") the #defineW (a) while (a--) + #definePB (a) push_back (a) - #defineRint (a) scanf ("%d", &a) $ #defineRll (a) scanf ("%lld", &a) $ #defineRs (a) scanf ("%s", a) - #defineCIN (a) CIN >> a - #defineFRead () freopen ("in", "R", stdin) the #defineFWrite () freopen ("Out", "w", stdout) - #defineRep (i, Len) for (int i = 0; i < (len); i++)Wuyi #defineFor (I, A, Len) for (int i = (a); I < (len); i++) the #defineCls (a) memset ((a), 0, sizeof (a)) - #defineCLR (A, X) memset ((a), (x), sizeof (a)) Wu #defineFull (a) memset ((a), 0x7f7f, sizeof (a)) - #defineLP P << 1 About #defineRP P << 1 | 1 $ #definePi 3.14159265359 - #defineRT return -typedefLong LongLL; -typedefLong DoubleLD; Atypedef unsignedLong LongULL; +typedef pair<int,int>PII; thetypedef pair<string,int>psi; -typedef map<string,int>MSI; $typedef vector<int>VI; thetypedef vector<ll>VL; thetypedef vector<vl>VVL; thetypedef vector<BOOL>vb; the - Const intMAXN =100010; intypedefstructBridge { the intu, v; the Bridge () {} AboutBridge (intUuintVV): U (UU), V (vv) {if(U >v) Swap (U, v); } the }bridge; the the intN; + intDFN[MAXN], LOW[MAXN]; - VI G[MAXN]; theVector<bridge>b;Bayi the voidDfsintUintDintp) { theLow[u] = Dfn[u] =D; - Rep (i, g[u].size ()) { - intv =G[u][i]; the if(!Dfn[v]) { theDFS (V, d+1, u); theLow[u] =min (Low[u], low[v]); the if(Low[v] >Dfn[u]) b.push_back (Bridge (U, v)); - } the Else if(P! = v) Low[u] =min (Low[u], dfn[v]); the } the }94 the BOOLCMP (bridge x, bridge y) { the if(x.u = = y.u)returnX.V <y.v; the returnX.u <y.u;98 } About - intMain () {101 //FRead ();102 intu, V, p;103 while(~Rint (n)) {104 if(n = =0) { theprintf"0 Critical links\n\n");106 Continue;107 }108 Cls (DFN); Cls (Low); B.cl ();109Rep (i, n+5) g[i].cl (); the Rep (i, n) {111 Rint (u); thescanf"(%d)", &p);113 W (p) { the Rint (v); the G[u].push_back (v); the g[v].push_back (u);117 }118 }119Rep (i, N)if(!dfn[i]) DFS (i,0, i); - sort (B.begin (), B.end (), CMP);121printf"%d critical links\n", B.size ());122 Rep (i, b.size ()) {123printf"%d-%d\n", b[i].u, B[I].V);124 } theprintf"\ n");126 }127Rt0; -}
[UVA796] Critical Links (Cutting edge, bridge)