Submission #630622

#TimeUsernameProblemLanguageResultExecution timeMemory
630622valerikkBitaro, who Leaps through Time (JOI19_timeleap)C++17
4 / 100
3058 ms8280 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, q; cin >> n >> q; vector<int> l, r; if (n > 1) { l.resize(n - 1); r.resize(n - 1); } for (int i = 0; i < n - 1; ++i) { cin >> l[i] >> r[i]; --r[i]; } while (q--) { int t; cin >> t; if (t == 1) { int p, s, e; cin >> p >> s >> e; --p, --e; l[p] = s; r[p] = e; } if (t == 2) { int a, b, c, d; cin >> a >> b >> c >> d; --a, --c; bool f = a > c; if (a > c) { reverse(begin(l), end(l)); reverse(begin(r), end(r)); a = n - a - 1; c = n - c - 1; } long long ans = 0; for (int i = a; i < c; ++i) { if (b > r[i]) { ans += b - r[i]; b = r[i]; } if (b < l[i]) { b = l[i]; } ++b; } if (b > d) { ans += b - d; b = d; } cout << ans << "\n"; if (f) { reverse(begin(l), end(l)); reverse(begin(r), end(r)); } } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...