版本比较
爱捷wiki(代码版)
正文
增加 42 行删除 42 行
294 行未改动全部展开295296297298299299300301302303190 行未改动全部展开49449549649749849849950050150228 行未改动53153253353453553553653753853954054154254354454454554654754854854955055155233 行未改动58658758858959059059159259359415 行未改动6106116126136146146156166176182 行未改动62162262362462562562662762862968 行未改动6986997007017027027037047057067 行未改动7147157167177187187197207217223 行未改动726727728729730730731732733734735736737737738739740741188 行未改动全部展开9309319329339349349359369379384 行未改动94394494594694794794894995095151 行未改动1003100410051006100710071008100910101011101210131013101410151016101710181019102010211021102210231024102548 行未改动1074107510761077107810781079108010811082173 行未改动全部展开125612571258125912601260126112621263126434 行未改动12991300130113021303130313041305130613072 行未改动131013111312131313141314131513161316131713181319131813191320132113221323132413241325132613271328132913301331133213311332133313341335133613371334133513361337133813391340134113401341134213431344134517 行未改动1363136413651366136713671368136913701371157 行未改动全部展开152915301531153215331533153415351536153745 行未改动1583158415851586158715871588158915901591107 行未改动全部展开1699170017011702170317031704170517061707378 行未改动全部展开2086208720882089209020902091209220932094209520962097209420952096209720982099210021012102294 行未改动全部展开|操作|数组|Vector|链表|哈希表|Queue|Stack|Deque||:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:||访问元素|$O(1)$|$O(1)$|$O(n)$|$O(1)$|$O(n)$|$O(n)$|$O(1)$||头部插入|$O(n)$|$O(n)$|$O(1)$|$O(1)$|-|-|$O(1)$||尾部插入|$O(1)$|$O(1)$|$O(1)$|$O(1)$|$O(1)$|$O(1)$|$O(1)$| |尾部插入|$O(1)$|$O(1)$|$O(1)$|$O(1)$|$O(1)$|$O(1)$|$O(1)$||中间插入|$O(n)$|$O(n)$|$O(1)$|-|-|-|-||头部删除|$O(n)$|$O(n)$|$O(1)$|-|$O(1)$|-|$O(1)$||尾部删除|$O(1)$|$O(1)$|$O(1)$|-|-|$O(1)$|$O(1)$||中间删除|$O(n)$|$O(n)$|$O(1)$|-|-|-|-|190 行未改动全部展开const int Mod=1e9+7;long long n,k;struct Node{ long long mx[MAXN][MAXN];}a,b,s; }a,b,s;Node operator *(const Node &a,const Node &b){ Node c; memset(c.mx,0,sizeof(c.mx)); for(int i=1;i<=n;i++)28 行未改动```#include<bits/stdc++.h>#include<cstdio>#define endl '\n'#define int long long #define int long long
const int N = 1e4 + 10;
using namespace std;
struct node{ int date; struct node* next;}; };
node* head=new node;
void add(int x,int y){ void add(int x,int y){ node* p=new node; p->date=y; p->next=NULL; node* q=head;33 行未改动 }}
signed main(){
head->date=1; head->next=NULL; int n; cin>>n;15 行未改动 cin>>x; del(x); } }
return 0;}```
2 行未改动```#include<bits/stdc++.h>#include<cstdio>#define endl '\n'#define int long long #define int long long
const int N = 1e4+10;
using namespace std;68 行未改动 }}
signed main(){
cin>>n>>qs; len=n; init(); while(qs--){7 行未改动 } else if(op==2){ cin>>x>>y; if(x==y)continue; del(x); del(x); addr(x,y); } else if(op==3){ int x;3 行未改动 } } if(len<=0){ cout<<"Empty!"<<endl; return 0; return 0; } node* q=head; while(q!=NULL){ cout<<q->data<<" "; q=q->next; }
return 0;}```
188 行未改动全部展开 cout.tie(0); cin>>n>>m; for(int i=1;i<=n;++i){ cin>>a[i]; add(i,a[i]-a[i-1]); add(i,a[i]-a[i-1]); } while(m--){ int op; cin>>op;4 行未改动 add(r+1,-k); } else{ int x;cin>>x; cout<<query(x)<<endl; cout<<query(x)<<endl; } } return 0;}51 行未改动 la=a.size()-1,lb=b.size()-1; for(int i=2;i<=lb;i++){ while(j&&b[i]!=b[j+1]) j=kmp[j]; if(b[j+1]==b[i]) if(b[j+1]==b[i]) j++; kmp[i]=j; } j=0; for(int i=1;i<=la;i++){ while(j>0&&b[j+1]!=a[i]) while(j>0&&b[j+1]!=a[i]) j=kmp[j]; if(b[j+1]==a[i]) j++; if(j==lb){ cout<<i-lb+1<<endl; j=kmp[j]; } } for(int i=1;i<=lb;i++) for(int i=1;i<=lb;i++) cout<<kmp[i]<<" "; return 0;}```48 行未改动 if(a[u*2]<a[t]&&u*2<=si)t=u*2; if(u*2+1<=si&&a[u*2+1]<a[t])t=u*2+1; if(t!=u){ swap(a[t],a[u]); doun(t); doun(t); }}void up(int u){ int t=u;173 行未改动全部展开 ansi[i]=p.top().first; } } for(int i=k;i<=n;i++)cout<<ansi[i]<<" "; cout<<endl; cout<<endl; for(int i=k;i<=n;i++)cout<<ansx[i]<<" "; return 0;}```34 行未改动 int l,r; cin>>l>>r; int o=log2(r-l+1); cout<<min(f[l][o],f[r-(1<<o)+1][o])<<" ";
} return 0;}```2 行未改动
```#include<bits/stdc++.h>using namespace std;int fa[30001],front[30001],num[30001],x,y,i,j,n,T,ans; int fa[30001],front[30001],num[30001],x,y,i,j,n,T,ans;char ins;int find(int n){ int find(int n){ if(fa[n]==n)return fa[n]; int fn=find(fa[n]); front[n]+=front[fa[n]]; int fn=find(fa[n]); front[n]+=front[fa[n]]; return fa[n]=fn;}int main(){ cin>>T; for(i=1;i<=30000;++i){ for(i=1;i<=30000;++i){ fa[i]=i; front[i]=0; num[i]=1; } while(T--){ cin>>ins>>x>>y; int fx=find(x); int fy=find(y); int fx=find(x); int fy=find(y); if(ins=='M'){ front[fx]+=num[fy]; fa[fx]=fy; num[fy]+=num[fx]; num[fx]=0; front[fx]+=num[fy]; fa[fx]=fy; num[fy]+=num[fx]; num[fx]=0; } if(ins=='C'){ if(fx!=fy)cout<<"-1"<<endl; else cout<<abs(front[x]-front[y])-1<<endl; if(fx!=fy)cout<<"-1"<<endl;else cout<<abs(front[x]-front[y])-1<<endl; } } return 0;}17 行未改动 else if(x>='a'&&x<='z') return x-'a'+26; else return x-'0'+52;} }void insert(char str[]){ int p=0,len=strlen(str); for(int i=0;i<len;i++){ int c=getnum(str[i]);157 行未改动全部展开 scanf("%d%d" , &w[i] , &v[i]); for(int i = 1;i <= N;i++) for(int j = w[i];j <= W;j++) dp[j] = max(dp[j] , dp[j - w[i]] + v[i]); printf("%d\n" , dp[W]); printf("%d\n" , dp[W]);}```
### 多重背包45 行未改动 for(int i = 1;i<=m;i++){ int l , r , x; cin >> l >> r >> x; b[l] += x; b[r + 1] -= x; b[r + 1] -= x; } for(int i = 1;i <= n;i++){ s[i] = s[i - 1] + b[i]; sum[i] = sum[i - 1] + s[i];107 行未改动全部展开 while(ch >= '0' && ch <= '9'){ x = (x << 1) + (x << 3) + (ch ^ 48); ch = GC; } return f? -x : x; return f? -x : x;}
bool dfs(int x){ visl[x] = true;378 行未改动全部展开```
# ——THE END——
$致谢$ $致谢$
$\small真菌团队$
$\tiny 主编:灵感菇。$ $\tiny 链接:金针菇,鸡油菌,鸡枞菌,青头菌。$ $\tiny 图片:奶浆菌,平菇,香菇,口蘑。$ $\tiny Markdown:毒蝇伞,珊瑚菌,出血齿菌,见手青。$ $\tiny 主编:灵感菇。$$\tiny 链接:金针菇,鸡油菌,鸡枞菌,青头菌。$$\tiny 图片:奶浆菌,平菇,香菇,口蘑。$$\tiny Markdown:毒蝇伞,珊瑚菌,出血齿菌,见手青。$$\tiny Katex:杏鲍菇,酵母菌,玉米瘤黑粉菌。$
一篇好的代码wiki需要尾图:
[](https://www.luogu.com.cn/user/645456)