Submission #129186

#TimeUsernameProblemLanguageResultExecution timeMemory
129186Mahmoud_AdelBitaro, who Leaps through Time (JOI19_timeleap)C++14
4 / 100
8 ms760 KiB
#include <bits/stdc++.h> using namespace std; #define f first #define s second typedef long long ll; const int N = 2005; int n, q, t, p, s, e, a, b, c , d, l[N], r[N]; int main() { cin >> n >> q; for(int i=0; i<n-1; i++) cin >> l[i] >> r[i]; while(q--) { cin >> t; if(t == 1) { cin >> p >> s >> e; l[p-1] = s, r[p-1] = e; } else { cin >> a >> b >> c >> d; ll ans = 0; if(a < c) { for(int i=a-1; i<c-1; i++) { b = max(b, l[i]); if(b >= l[i] && b < r[i]) b++; else ans += b-r[i]+1, b = r[i]; } } else { for(int i=a-2; i>=c-1; i--) { //cout << b << " " << ans << endl; b = max(b, l[i]); if(b >= l[i] && b < r[i]) b++; else ans += b-r[i]+1, b = r[i]; } //cout << "--------------------------\n"; } cout << ans + max(0, b-d) << endl; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...