download:Django from beginner to Advanced – suitable for Python systems courses

Master the basic knowledge of Django, learn the relevant extension knowledge of Web, learn to develop C/S service and Apiserver service; Learn how to configure and develop a variety of non-Django built-in modules. Learn final server deployment scenarios for a real production environment; A comprehensive overview of Web development will help you learn how to use Python-based Web services with or without Django. It will cover most of the Python Web development ecology as much as possible, and will be easy to understand and friendly to beginners

Suitable for people who are getting started with Python, those who are new to Web development, those who do Python operations and maintenance (Web business development based on Django), those who do Python tests, Technical Reserves requirements: Basic knowledge of Python, basic understanding of front-end {// open the path from the root node to x, x deepest for(R y=0; x; x=fa(y=x)) { splay(x),rs(x)=y,pushup(x); }} Make_root(x) : make x the root node

IL void makeroot(int x) {// Change x to the root of the tree access(x),splay(x),Rev(x); } Find_root(x) : finds the root node of x

IL int findroot(int x) {// Find the root of the x tree access(x),splay(x); while(ls(x)) pushdown(x),x=ls(x); return x; } Spilt(x,y) : converts the path from x to y into a real-edge path

IL void split(int x,int y) {//y makeroot(x),access(y),splay(y); } Link(x,y) : join (x,y) if x,y is not connected

IL void link(int x,int y) { makeroot(x); if(findroot(y)! =x) fa(x)=y; } Cut(x,y) : if there is a edge between x and y, delete the edge

IL void cut(int x,int y) { split(x,y); if(fa(x)==y&&rs(x)==0) fa(x)=ls(y)=0,pushup(y); } Isroot(x) : checks whether x is the root node of the splay

IL int nroot (int x) / / return 1 to clarify the x is not the root, returns 0 to clarify {x is the root return ls (fa) (x) = = x | | rs (fa) (x) = = x; } P3690 【 template 】Link Cut Tree (dynamic Tree

! [] ()! []()“` 1 #include

2 #define IL inline 3 #define R register int 4 #define ls(x) a[x].ch[0] 5 #define rs(x) a[x].ch[1] 6 #define fa(x) a[x].fa 7 8 using namespace std; 9 const int N=1e5+5,inf=0x3f3f3f3f; 10 11 IL int read() { 12 int f=1; 13 char ch; 14 while((ch=getchar())<‘0’||ch>’9′) if(ch==’-‘) f=-1; 15 int res=ch-‘0′; 16 while((ch=getchar())>=’0’&&ch<=’9’) res=res10+ch-‘0’; 17 return resf; 18 } 19 20 int n,m; 21 struct hh { 22 int ch[2],fa,val,rev,sum; 23 } a[N]; 24 25 IL int chk(int x) {return x==rs(fa(x)); } 26 IL void Rev(int x) {swap(ls(x),rs(x)); a[x].rev^=1; } 27 IL void pushup(int x) {a[x].sum=a[ls(x)].sum^a[rs(x)].sum^a[x].val; } IL 28 int nroot (int x) / / return 1 to clarify the x is not the root, returns 0 to clarify x is the root of 29 {return ls (fa) (x) = = x | | rs (fa) (x) = = x; } 30 31 IL void pushdown(int x) { 32 if(a[x].rev) { 33 a[x].rev=0; 34 if(ls(x)) Rev(ls(x)); 35 if(rs(x)) Rev(rs(x)); 36 } 37 } 38 39 IL void pushall(int x) { 40 if(nroot(x)) pushall(fa(x)); 41 pushdown(x); 42 } 43 44 IL void rotate(int x) { 45 int y=fa(x),z=fa(y),k=chk(x),w=a[x].ch[k^1]; 46 if(nroot(y)) a[z].ch[chk(y)]=x; fa(x)=z; 47 if(w) fa(w)=y; a[y].ch[k]=w; 48 fa(y)=x; a[x].ch[k^1]=y; 49 pushup(y); pushup(x); 50} 51 52 IL void splay(int x) {// convert x to splay(x); 54 while(nroot(x)) { 55 int y=fa(x); 56 if(nroot(y)) rotate(chk(x)^chk(y)? x:y); 57 rotate(x); 58} 59} 60 61 IL void access(int x) {for(R y=0; x; x=fa(y=x)) { 63 splay(x),rs(x)=y,pushup(x); 64} 65} 66 67 IL void makeroot(int x) {// access(x),splay(x),Rev(x); 69} 70 71 IL int findroot(int x) {// access(x),splay(x); 73 while(ls(x)) pushdown(x),x=ls(x); 74 return x; 75} 76 77 IL void split(int x,int y) {//y 79 } 80 81 IL void link(int x,int y) { 82 makeroot(x); if(findroot(y)! =x) fa(x)=y; 83 } 84 85 IL void cut(int x,int y) { 86 split(x,y); 87 if(fa(x)==y&&rs(x)==0) fa(x)=ls(y)=0,pushup(y); 88 } 89 90 int main() { 91 n=read(); 92 m=read(); 93 for(R i=1; i<=n; ++i) a