제출 #630907

#제출 시각아이디문제언어결과실행 시간메모리
630907valerikkBitaro, who Leaps through Time (JOI19_timeleap)C++17
0 / 100
3061 ms8072 KiB
#include <bits/stdc++.h> using namespace std; int solve(vector<int> l, vector<int> r) { int n = l.size(); int t = -1; int res = 0; for (int i = 0; i < n; ++i) { if (t > r[i]) { res += t - r[i]; t = r[i]; } if (t < l[i]) { t = l[i]; } ++t; } return res; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, q; cin >> n >> q; vector<int> l(n), r(n); 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; if (a == c) { cout << max(0, b - d) << "\n"; } else { vector<int> cl, cr; cl.push_back(b - 1); cr.push_back(b - 1); if (a < c) { for (int i = a; i < c; ++i) { cl.push_back(l[i]); cr.push_back(r[i]); } } else { for (int i = a - 1; i >= c; --i) { cl.push_back(l[i]); cr.push_back(r[i]); } } cl.push_back(d); cr.push_back(d); cout << solve(cl, cr) << "\n"; } } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...