Submission #1234164

#TimeUsernameProblemLanguageResultExecution timeMemory
1234164antonnBitaro, who Leaps through Time (JOI19_timeleap)C++20
4 / 100
3094 ms4908 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 3e5 + 7; int n, q, l[N], r[N], l2[N], r2[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n >> q; for (int i = 1; i < n; ++i) cin >> l[i] >> r[i], r[i]--; for (int i = 1; i < n; ++i) l2[i] = l[i] + i + 1, r2[i] = r[i] + i + 1; for (int i = 1; i < n; ++i) l[i] -= i, r[i] -= i; while (q--) { int t; cin >> t; if (t == 1) { int p, s, e; cin >> p >> s >> e; --e; l[p] = s - p; r[p] = e - p; l2[p] = s + p + 1; r2[p] = e + p + 1; } else { int a, b, c, d; cin >> a >> b >> c >> d; if (a < c) { int t = b - a; ll ans = 0; for (int i = a; i < c; ++i) { if (t > r[i]) { ans += t - r[i]; t = r[i]; } else { t = max(t, l[i]); } } ans += max(0, t - (d - c)); cout << ans << "\n"; } else { int t = b + a; ll ans = 0; for (int i = a - 1; i >= c; --i) { if (t > r2[i]) { ans += t - r2[i]; t = r2[i]; } else { t = max(t, l2[i]); } } ans += max(0, t - (d + c)); cout << ans << "\n"; } } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...