版本比较
「LKJOI R1 D」和谐灯带 题解
正文
增加 19 行删除 19 行
93 行未改动9495969798989910010110210310410510610710810810911011111216 行未改动12913013113213313313413513613731 行未改动16917017117217317317417517617724 行未改动2022032042052062062072082092104 行未改动21521621721821921922022122222322422422522622722822923023123223323323423523623716 行未改动2542552562572582582592602612625 行未改动2682692702712722732722732742752762772 行未改动28028128228328428428528628728834 行未改动3233243253263273273283293303313 行未改动33533633733833933934034134234334434434534634734834935035135235335335435535635724 行未改动3823833843853863863873883893909 行未改动40040140240340440540440540640793 行未改动 } } if(x==y){ rc=rc+f[x][0];
} else{ for(int j=20;j>=0;j--){ if(f[x][j].x!=f[y][j].x){ rc=rc+f[x][j]; rc=rc+f[y][j]; x=f[x][j].x; y=f[y][j].x; } } } rc=rc+f[x][0]; rc=rc+f[y][0]; x=f[x][0].x; rc=rc+f[x][0];16 行未改动
代码见下:
```cpp#include<bits/stdc++.h> #include<bits/stdc++.h>using namespace std;int n,aa,bb,a[1500006],m,u,v1;string str;vector<int> v[1500006];31 行未改动 int tt=v[a1][i]; if(tt!=fa[a1]&&tt!=son[a1]){ abc2(tt,tt); } } } return ;}char s[1500006],s2[1500006];inline void bu(int a1,int l,int r){24 行未改动 int mid=(l+r)/2; two cc={0,0,0}; if(x<=mid){ cc=cc+akx(a1*2,l,mid,x,y); } } if(y>mid){ cc=cc+akx(a1*2+1,mid+1,r,x,y); } return cc;4 行未改动 if(de[top[a1]]<de[top[b1]]){ swap(a1,b1); } cc=cc+akx(1,1,n,w[top[a1]],w[a1]); a1=fa[top[a1]]; a1=fa[top[a1]]; } if(de[a1]>de[b1]){ swap(a1,b1); } return cc+akx(1,1,n,w[a1],w[b1]); return cc+akx(1,1,n,w[a1],w[b1]);}char *p1,*p2,buf[100000];#define nc() (p1==p2 && (p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)inline int read(){ int x=0; char ch=nc(); while(ch<=47||ch>=58){ ch=nc(); } } while(ch>=48&&ch<=57){ x=(x<<3)+(x<<1)+ch-48; ch=nc(); }16 行未改动 abc2(1,1); for(int i=1;i<=n;i++){ s2[w[i]]=s[i]; //cout<<w[i]<<endl; } } // cout<<n<<endl; bu(1,1,n); // cout<<1<<endl; for(int i=1;i<=m;i++){5 行未改动 } else{ cout<<"No\n"; } } return 0; } return 0;}```
## 100分(AC)2 行未改动
代码见下(AC):
```cpp#include<bits/stdc++.h> #include<bits/stdc++.h>using namespace std;int n,aa,bb,a[1500006],m,u,v1;string str;vector<int> v[1500006];34 行未改动 int tt=v[a1][i]; if(tt!=fa[a1]&&tt!=son[a1]){ abc2(tt,tt); } } } return ;}char s[1500006],s2[1500006];inline two cox(int a1,int b1){3 行未改动 swap(a1,b1); } cc=cc+te[w[a1]]-te[w[top[a1]]-1]; //cout<<w[a1]<<" "<<w[top[a1]]-1<<endl; a1=fa[top[a1]]; a1=fa[top[a1]]; } if(de[a1]<de[b1]){ swap(a1,b1); } return cc+te[w[a1]]-te[w[b1]-1]; return cc+te[w[a1]]-te[w[b1]-1];}char *p1,*p2,buf[100000];#define nc() (p1==p2 && (p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++)inline int read(){ int x=0; char ch=nc(); while(ch<=47||ch>=58){ ch=nc(); } } while(ch>=48&&ch<=57){ x=(x<<3)+(x<<1)+ch-48; ch=nc(); }24 行未改动 else{ te[w[i]]={0,0,1}; } //cout<<w[i]<<endl; } } for(int i=1;i<=n;i++){ te[i]=te[i]+te[i-1]; } // cout<<n<<endl;9 行未改动 } else{ cout<<"No\n"; } } return 0; } return 0;}```