1 #include<cstdio> 2 #include<cstring> 3 #include<queue> 4 #include<vector> 5 #define $ 220010 6 using namespace std; 7 int m,n,q,first[$],tot1,dfn[$],low[$],tar,tip[$],second[$],tot2,cut[$],cnt; 8 int dad[$*2][22],sta[$],up,ans[$],dep[$],sum,pre[$],cir[$],id[$],data[$]; 9 vector<int> dcc[$]; 10 struct tree{ int to,next; }a[$*5],tr[$*5]; 11 inline int min(int x,int y) { return x<y?x:y; } 12 inline void swap(int &x,int &y){ int t=x; x=y; y=t; } 13 inline void add(int x,int y){ 14 a[++tot1]=(tree){ y,first[x] }; 15 first[x]=tot1; 16 a[++tot1]=(tree){ x,first[y] }; 17 first[y]=tot1; 18 } 19 inline void addtr(int x,int y){ 20 tr[++tot2]=(tree){ y,second[x] }; 21 second[x]=tot2; 22 tr[++tot2]=(tree){ x,second[y] }; 23 second[y]=tot2; 24 } 25 inline void tarjan(int x,int opt=0){ 26 dfn[x]=low[x]=++tar; sta[++up]=x; 27 for(register int i=first[x],tmp;i;i=a[i].next){ 28 int to=a[i].to; 29 if(!dfn[to]){ 30 tarjan(to); 31 low[x]=min(low[x],low[to]); 32 if(low[to]>=dfn[x]){ 33 opt++; sum++; 34 if(x!=1||opt>1) cut[x]=1; 35 do{ 36 tmp=sta[up--]; 37 cir[tmp]=sum; 38 dcc[sum].push_back(tmp); 39 }while(tmp!=to); 40 cir[x]=sum; 41 dcc[sum].push_back(x); 42 } 43 } 44 else low[x]=min(low[x],dfn[to]); 45 } 46 } 47 inline void ready(int x){ 48 pre[--pre[0]]=x; 49 for(register int i=second[x];i;i=tr[i].next){ 50 int to=tr[i].to; 51 if(to==dad[x][0]) continue; 52 dad[to][0]=x; 53 for(register int j=1;j<=20;++j) dad[to][j]=dad[dad[to][j-1]][j-1]; 54 dep[to]=dep[x]+1; 55 ready(to); 56 } 57 } 58 inline int LCA(int x,int y){ 59 if(dep[x]<dep[y]) swap(x,y); 60 for(register int i=20;i>=0;--i) 61 if(dep[dad[x][i]]>=dep[y]) x=dad[x][i]; 62 if(x==y) return x; 63 for(register int i=20;i>=0;--i) 64 if(dad[x][i]!=dad[y][i]) x=dad[x][i],y=dad[y][i]; 65 return dad[x][0]; 66 } 67 signed main(){ 68 scanf("%d%d%d",&n,&m,&q); cnt=n; 69 for(register int i=1,x,y;i<=m;++i) scanf("%d%d",&x,&y),add(x,y); 70 tarjan(1); 71 for(register int i=1;i<=n;++i) if(cut[i]) cir[i]=id[i]=++cnt; 72 for(register int i=1;i<=sum;++i) 73 for(register int j=0;j<dcc[i].size();++j){ 74 int to=dcc[i][j]; 75 if(cut[to]) addtr(i,id[to]); 76 } 77 pre[0]=cnt+1; dep[1]=1; 78 ready(1); 79 for(register int i=1,x,y,lca;i<=q;++i){ 80 scanf("%d%d",&x,&y); 81 if(!cut[x]) data[x]++; 82 if(!cut[y]) data[y]++; 83 x=cir[x], y=cir[y]; 84 lca=LCA(x,y); 85 ++ans[x]; ++ans[y]; 86 --ans[lca]; --ans[dad[lca][0]]; 87 } 88 for(register int i=1,x;i<=cnt;++i) 89 x=pre[i],ans[dad[x][0]]+=ans[x]; 90 for(register int i=1;i<=n;++i) printf("%d\n",cut[i]?ans[cir[i]]:data[i]); 91 }