版本比较
CF1787I Treasure Hunt
正文
增加 7 行删除 7 行
14 行未改动151617181920212223242526272829303132333435363738 行未改动7677787980818283848586878821 行未改动11011111211311411511611714 行未改动### $\color{skyblue}{\mathsf{Code}}$```cpp#include <bits/stdc++.h>using namespace std;using ll = long long;const int N = 1e6 + 5;const int mod = 998244353;int n, top;int a[N], stk[N];ll ans;ll pre[N], f[N];ll lans[N], lmax[N];ll rans[N], rmax[N];ll prans[N], prmax[N];void cdq(int L, int R) {if (L == R) return ans += (a[L] > 0 ? a[L] : 0), void();int mid = (L + R) >> 1;cdq(L, mid), cdq(mid + 1, R);38 行未改动}}ans = (ans + res) % mod;}int main() {ios_base::sync_with_stdio(false);cin.tie(nullptr);int T;cin >> T;while (T--) {cin >> n;21 行未改动}cdq(1, n);cout << ans << '\n';}return 0;}```14 行未改动151617181920212223242526272829303132333435363738 行未改动7677787980818283848586878821 行未改动11011111211311411511611714 行未改动### $\color{skyblue}{\mathsf{Code}}$```cpp#include <bits/stdc++.h>using namespace std;using ll = long long;const int N = 1e6 + 5;const int mod = 998244353;int n, top;int a[N], stk[N];ll ans;ll pre[N], f[N];ll lans[N], lmax[N];ll rans[N], rmax[N];ll prans[N], prmax[N];void cdq(int L, int R) {if (L == R) return ans += (a[L] > 0 ? a[L] : 0), void();int mid = (L + R) >> 1;cdq(L, mid), cdq(mid + 1, R);38 行未改动}}ans = (ans + res) % mod;}int main() {ios_base::sync_with_stdio(false);cin.tie(nullptr);int T;cin >> T;while (T--) {cin >> n;21 行未改动}cdq(1, n);cout << ans << '\n';}return 0;}```