好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Tornado从入门到进阶 打造支持高并发的技术论坛

download:Tornado从入门到进阶 打造支持高并发的技术论坛

在本课程中,我们从tornado的基础开发到项目实战进行系统讲解,覆盖理论与实践,完成本课程可以更透彻的理解异步IO并发编程思想,以及正确使用tornado进行并发编程,做一个支持高并发的技术论坛项目!

适合人群

从事Python异步IO并发开发相关的开发人员

以及对Python并发编程感兴趣的开发人员

技术储备要求

有一定的编程功底,了解Python socket编程,

了解web开发和网络协议 ![]()![]()``` 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn=3e5+10; 4 const int mod=1e9+7; 5 #define ll long long 6 #define pi pair<int,int> 7 #define fi first 8 #define sc second 9 #define pb push_back 10 int cnt[maxn][2]; 11 int a[maxn]; 12 vectorE[maxn]; 13 int ans,n; 14 int cntr,cntb; 15 16 void dfs(int u,int fa) 17 { 18 if(a[u]==1) cnt[u][1]++; 19 if(a[u]==2) cnt[u][0]++; 20 for(auto &v:E[u]) 21 { 22 if(v==fa) continue; 23 dfs(v,u); 24 cnt[u][0]+=cnt[v][0]; 25 cnt[u][1]+=cnt[v][1]; 26 if(cnt[v][1]==cntr&&cnt[v][0]==0) 27 ans++; 28 if(cnt[v][0]==cntb&&cnt[v][1]==0) 29 ans++; 30 } 31 } 32 33 34 int main() 35 { 36 ios::sync_with_stdio(0); 37 cin.tie(0); 38 cin>>n; 39 for(int i=1;i<=n;i++) cin>>a[i],cntr+=a[i]==1,cntb+=a[i]==2; 40 for(int i=1;i<n;i++) 41 { 42 int x,y; 43 cin>>x>>y; 44 E[x].pb(y); 45 E[y].pb(x); 46 } 47 if(cntr&&cntb) 48 dfs(1,0); 49 else 50 ans=n-1; 51 cout<<ans<<'\n'; 52 53 54 55 56 57 }

查看更多关于Tornado从入门到进阶 打造支持高并发的技术论坛的详细内容...

  阅读:31次