版本比较
SJY的模版
正文
增加 20 行删除 20 行
37 行未改动383940414242434444454647484950505152525354555687 行未改动14414514614714814814915015115240 行未改动1931941951961971971981992002012022032042052062062072082092109 行未改动2202212222232242242252262262272282292302312322332332342352362373 行未改动2412422432442452452462472482494 行未改动254255256257258258259260260261262263264140 行未改动全部展开40540640740840941040941041141241341410 行未改动42542642742842942943043143243363 行未改动49749849950050150150250350450562 行未改动56856957057157257257357457557624 行未改动601602603604605605606607608609106 行未改动全部展开7167177187197207207217227237247 行未改动37 行未改动inline void read() { char c = getchar(); s[0] = '~'; s[cnt = 1] = '|'; while(c < 'a' || c > 'z') while(c < 'a' || c > 'z') c = getchar(); while(c >= 'a' && c <= 'z') while(c >= 'a' && c <= 'z') s[++cnt] = c,s[++cnt] = '|',c = getchar();}void work(){ read(); for(int i=1;i<=cnt;i++){ if(i <= r) if(i <= r) p[i] = min(p[mid * 2 - i],r - i + 1); while(s[i - p[i]] == s[i + p[i]]) while(s[i - p[i]] == s[i + p[i]]) ++p[i]; if(p[i] + i > r){ r = p[i] + i - 1; mid = i;87 行未改动 }else{ cin >> x >> y; cout << query(x,y) << "\n"; } } }}int main(){ //ios::sync_with_stdio(false); //cin.tie(nullptr);cout.tie(nullptr);40 行未改动 push(x,y); else{ cout << add(y) - add(x-1) << endl; } } }}int main(){ //ios::sync_with_stdio(false); //cin.tie(nullptr);cout.tie(nullptr); //freopen(".in","r",stdin); //freopen(".out","w",stdout); int T = 1; while(T--){ work();}
return 0;}```
9 行未改动const ll M = 1e5 + 5;const ll INF = 1e9 + 7;const ll MOD = 1e9 + 7;ll n,m,a[N];ll c[N]; ll c[N];ll lowbit(ll x){ return x & (-x);}void add(ll x,ll k){ void add(ll x,ll k){ while(x <= n){ c[x] += k; x += lowbit(x); } return;}ll sum(ll x){ ll sum(ll x){ ll res = 0; while(x){ res += c[x]; x -= lowbit(x);3 行未改动void work(){ 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--){ ll op; cin >> op;4 行未改动 add(r + 1,-k); }else{ ll x; cin >> x; cout << sum(x) << "\n"; cout << sum(x) << "\n"; } } }}int main(){ //ios::sync_with_stdio(false); //cin.tie(nullptr);cout.tie(nullptr);140 行未改动全部展开void work(){ n = read(),m = read(),s = read(),mod = read(); for(ll i=1;i<=n;i++) w[i] = read(); for(ll i=1;i<n;i++){ ll u,v;u = read(),v = read();add(u,v);} f[s] = 0; deep[s] = 1; f[s] = 0; deep[s] = 1; dfs1(s,0); dfs2(s,s); build(1,n,1); for(ll i=1,x,y,z;i<=m;i++){10 行未改动 z = read(); update(id[x],id[x] + size[x] - 1,z,1,n,1); } if(k == 4) printf("%lld\n",query(id[x],id[x] + size[x] - 1,1,n,1) % mod); } }}int main(){ //ios::sync_with_stdio(false); //cin.tie(nullptr);cout.tie(nullptr);63 行未改动 while(m--){ ll x,y; cin >> x >> y; cout << LCA(x,y) << endl; } }}int main(){ ios::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr);62 行未改动 while(m--){ int x,y; cin >> x >> y; cout << LCA(x,y) << endl; } }}int main(){ ios::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr);24 行未改动 deep[u] = deep[fa] + 1; f[u] = fa; for(auto v : E[u]){ if(v != fa){
dfs1(v,u); size[u] += size[v]; if(size[v] > size[son[u]]) son[u] = v; }106 行未改动全部展开 E[y].push_back({x,i}); } dfs(s,0); for(ll i=1;i<=m;i++) cout << ans[i] << endl; cout << ans[i] << endl;}int main(){ ios::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr);7 行未改动