cf949c Data Center Maintenance (build + strong Unicom component)

Source: Internet
Author: User

Test instructions

There are n information centers, and the I Information Center is to be maintained during the TI hours, and during maintenance, the message cannot be obtained.

Each user's data is backed up by two copies, and the data for the I user is placed in Information Center C (i,1) and C (i,2).

Now to pick a small collection of information centers, so that the maintenance time of this set is delayed one hours, still can ensure that each user's data at any time can be obtained.

n≤100000

For each pair of C (i,1), C (i,2), if you adjust C (i,1) and C (i,2) after the maintenance time conflict, then the Edge (C (i,1), C (i,2)) for C (i,2), C (i,1) and the strong connected component, the set is the smallest SCC with a degree of 0 after the contraction point
1#include <iostream>2#include <cstring>3#include <cstdio>4#include <algorithm>5#include <cmath>6 using namespacestd;7 Const intn=500100;8 intCnt,head[n];9 intDfn[n],low[n],stack[n],vis[n],w[n],c[n],num,tot,top;Ten intN,m,h,t[n],ans,a[n],b[n],deg[n]; One structedge{ A     intto,nxt; - }e[n]; - voidAddintUintv) { thecnt++; -e[cnt].nxt=Head[u]; -e[cnt].to=v; -head[u]=CNT; + } - voidTarjan (intu) { +dfn[u]=low[u]=++tot; Astack[++top]=u; atvis[u]=1; -      for(intI=head[u];i;i=e[i].nxt) { -         intv=e[i].to; -         if(dfn[v]==0){ - Tarjan (v); -low[u]=min (low[u],low[v]); in         } -         Else if(Vis[v]) low[u]=min (low[u],dfn[v]); to     } +     if(low[u]==Dfn[u]) { -         intx; thenum++; *          Do{ $x=stack[top--];Panax Notoginsengc[x]=num+N; -w[num+n]++; theAdd (num+n,x); +vis[x]=0; A} while(x!=u); the     } + } - intMain () { $scanf"%d%d%d",&n,&m,&h); $      for(intI=1; i<=n;i++){ -scanf"%d",&t[i]); -     } the      for(intI=1; i<=m;i++){ -scanf"%d%d",&a[i],&b[i]);Wuyi         if(t[a[i]]+1==t[b[i]]| | (t[a[i]]==h-1&&t[b[i]]==0) Add (A[i],b[i]); the         if(t[b[i]]+1==t[a[i]]| | (t[b[i]]==h-1&&t[a[i]]==0) Add (B[i],a[i]); -     } Wu      for(intI=1; i<=n;i++){ -         if(dfn[i]==0) Tarjan (i); About     } $      for(intI=1; i<=m;i++){ -         if(C[a[i]]==c[b[i]])Continue; -         if(t[a[i]]+1==t[b[i]]| | (t[a[i]]==h-1&&t[b[i]]==0)) deg[c[a[i]]]++; -         if(t[b[i]]+1==t[a[i]]| | (t[b[i]]==h-1&&t[a[i]]==0)) deg[c[b[i]]]++; A     } +     intminn=9999999; the      for(inti=n+1; i<=n+num;i++){ -         if(deg[i]==0&&minn>W[i]) { $minn=W[i]; theans=i; the         } the     } theprintf"%d\n", W[ans]); -      for(intI=head[ans];i;i=e[i].nxt) { in         intv=e[i].to; theprintf"%d", v); the     }  About     return 0; the}
View Code

cf949c Data Center Maintenance (build + strong Unicom component)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.