code——tmp

來源:互聯網
上載者:User

標籤:std   efi   nod   void   getch   idg   get   cpp   print   

#include<queue> #include<vector> #include<cstdio> #include<algorithm> #define pc putchar#define gc getchar() #define rep(a,b,c) for(int a = b;a <= c;++ a) #define per(a,b,c) for(int a = b;a >= c;-- a) inline int read() {     int x = 0,f = 1;     char c = gc;     while(c < '0' || c > '9') c = gc;     while(c <= '9' && c >= '0') x = x * 10 + c - '0',c = gc;     return x * f ;} void print(int x) {     if(x < 0) {         pc('-'); x = -x;     }     if(x >= 10) print(x / 10);     pc(x % 10 + '0');   } const int maxn = 100007; int a[maxn << 1]; struct node {    int v,next;     bool cut; } edge[maxn << 1]; int head[maxn],num = 1; inline void add_edge(int u,int v) {    edge[++ num].v = v; edge[num].next = head[u];head[u] = num;     e[num].cut = 0 ;} bool vis[maxn]; void tarjan(int x,int fa) {     low[x] = dfn[x] = ++ index;     stk[++ top] = x;     vis[x] = 1;     for(int i = head[x];i;i = edge[i].next) {         int v = edge[i].v;         if(v == fa) continue;         if(!dfn[v]) {             tarjan(v,x);             low[x] = std::min(low[x],low[v]);             if(low[v] > dfn[u]) {                 bridge ++;                 edge[i].cut = true;                 edge[i ^ 1].cut = true;             }         }         else if(vis[v] && low[u] > dfn[v])             low[u] = dfn[v];      }     if(dfn[x] == low[x]) {              }  void solve() {     n = read();m = read();     for(int u,v,i = 1;i <= m;++ i) {         u = read(),v = read();         add_edge(u,v);         add_edge(v,u);     }     memset(dfn,0,sizeof dfn);     top = block = index = bridge = 0;     for(int i = 1;i <= n;++ i) if(!dfn[i]) tarjan(i,i);      } int main() {        int t = read();     for(int i = 1;i <= t;++ i) {         memset(head,0,szieof head); num = 0;         solve();     }  } 

code——tmp

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.