版本比较
5.6
正文
增加 14 行删除 14 行
18 行未改动192021222323242526272 行未改动303132333434353637389 行未改动4849505152525354555617 行未改动7475767778787980818228 行未改动11111211311411511511611711811916 行未改动13613713813914014114014114214314414514414514614714714814914915015115215315415515515615715815961 行未改动2212222232242252252262272282292 行未改动23223323423523623623723823918 行未改动 cin>>n>>a; a="&"+a+"0"; for(int i=1;i<=n+1;i++){ if(a[i-1]!=a[i]&&a[i]=='1')cnt=1; if(a[i-1]=='1'&&a[i]=='1')cnt++; if(a[i-1]=='1'&&a[i]=='1')cnt++; if(a[i-1]!=a[i]&&a[i-1]=='1'){ if(i==cnt+1||i==n+1)res=min(res,cnt-1); else res=min(res,(cnt-1)/2); dick.push_back(cnt),cnt=0;2 行未改动 } for(auto x:dick)ans+=ceil(x*1.0/(res*2+1)); cout<<ans; return 0;} }
```
9 行未改动
```cpp#include<bits/stdc++.h>using namespace std;#define int long long #define int long longconst int N=1e5+7891;int n,a[N],t[N],sb[N],ans;int lowbit(int x){return x&-x;}void add(int i,int v){for(;i<=n;i+=lowbit(i))t[i]+=v;}17 行未改动
```cpp#include<bits/stdc++.h>using namespace std;#define int long long #define int long longconst int N=1e5+5;int n,m,lim[N],dis[N],ans;bool vis[N];struct edge{28 行未改动 } for(int i=1;i<=m;i++)ans=max(ans,lim[i]*(int)(1e6)/dij(lim[i])); cout<<ans; return 0;} }```
T416 行未改动 multiset<int> f; for (int i = 0; i < a[x].size(); ++i) { int u = a[x][i]; if (u == y) continue; int v = dfs(u, x) + 1; if (v == k) continue; int v = dfs(u, x) + 1; if (v == k) continue; if (f.count(k - v)) { auto t = f.find(k - v); f.erase(t); } else f.insert(v); f.erase(t); } else f.insert(v); } if (f.size() > 1) fl = 1; if (f.size() > 1) fl = 1; if (f.empty()) return 0; else return *f.begin(); else return *f.begin();}int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; n--; n--; for (int i = 1; i <= n; ++i) { int x, y; cin >> x >> y; a[x].push_back(y);61 行未改动 } sort(b+1,b+t+1); t = unique(b+1, b+t+1)-b-1; for (int i = 1; i <= tot; ++i)e[i].y =lower_bound(b+1, b+t+1, e[i].y) - b; sort(e+1, e+tot+1,cmp); sort(e+1, e+tot+1,cmp); memset(c,0x3f3f3f3f,sizeof c); for (int i=1; i<=tot;++i) { if (e[i].type==1) { int idx = e[i].id;2 行未改动 int idx = e[i].id; add(e[i].y, dp[idx]-e[i].x-b[e[i].y]); } } cout<< dp[p + 1]; cout<< dp[p + 1]; return 0;}```