主页
搜索
最近更新
数据统计
赞助我们
申请密钥
系统公告
1
/
1
请查看完所有公告
AT
最后更新于 2025-07-07 10:58:36
作者
CSP_SAKME
分类
个人记录
复制 Markdown
查看原文
删除文章
更新内容
# 102133 - [AtCoder]ABC213 D - Takahashi Tour ```cpp #include <bits/stdc++.h> using namespace std; vector<int> a[200010]; bool vis[200010]; void dfs(int now) { cout << now << ' '; vis[now] = true; for (int i = 0; i < a[now].size(); i++) if (!vis[a[now][i]]) dfs(a[now][i]), cout << now << ' '; } int main(){ ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); int n; cin >> n; for (int i = 1; i < n; i++) { int u, v; cin >> u >> v; a[u].push_back(v); a[v].push_back(u); } for (int i = 1; i <= n; i++) sort(a[i].begin(), a[i].end()); dfs(1); return 0; } ``` # 101333 - [AtCoder]ABC133 D - Rain Flows into Dams ```cpp #include <bits/stdc++.h> using namespace std; long long n,k=1,t; long long sum,a[100001],b[100001]; int main(){ cin >> n; for(int i=1;i<=n;i++){ cin >> a[i]; sum+=a[i]; a[i]*=2; } while(k!=n){ t+=a[k]; k+=2; } b[n]=sum-t; b[1]=a[n]-b[n]; for(int i=2;i<n;i++){ b[i]=a[i-1]-b[i-1]; } for(int i=1;i<=n;i++) cout << b[i] << " "; return 0; } ``` # 102053 - [AtCoder]ABC205 D - Kth Excluded ```cpp #include <bits/stdc++.h> using namespace std; long long n,q; long long a[100001],s[100001],x; int main(){ cin >> n >> q; for (int i=1;i<=n;i++){ cin >> a[i]; } sort(a+1,a+n+1); for(int i=1;i<=n;i++){ s[i]=s[i-1]+(a[i]-a[i-1]-1); } for(int i=1;i<=q;i++){ cin >> x; if(x>s[n]) cout << x+n << endl; else{ long long k; int l=0,r=n; while(l<=r){ int mid=(l+r)>>1; if(s[mid]>=x){ k=mid; r=mid-1; }else{ l=mid+1; } } cout << a[k-1]+(x-s[k-1]) << endl; } } return 0; } ``` # 103663 - [Atcoder]ABC366 D - Cuboid Sum Query ```cpp #include <bits/stdc++.h> using namespace std; long long n,q; long long a[101][101][101],s[101][101][101]; int main(){ cin >> n; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ for(int k=1;k<=n;k++){ cin >> a[i][j][k]; s[i][j][k]=s[i][j-1][k]+s[i][j][k-1]-s[i][j-1][k-1]+a[i][j][k]; } } } cin >> q; while(q--){ int lx,ly,lz,rx,ry,rz; long long ans=0; cin >> lx >> rx >> ly >> ry >> lz >> rz; for(int i=lx;i<=rx;i++){ long long p=s[i][ry][rz]-s[i][ry][lz-1]-s[i][ly-1][rz]+s[i][ly-1][lz-1]; ans+=p; } cout << ans << endl; } return 0; } ```
正在渲染内容...
点赞
0
收藏
0