Submission #865305

#TimeUsernameProblemLanguageResultExecution timeMemory
865305LittleOrangeBitaro, who Leaps through Time (JOI19_timeleap)C++17
4 / 100
3069 ms5096 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(0);cin.tie(0); ll n,q; cin >> n >> q; vector<ll> L(n-1),R(n-1); for(ll i = 0;i<n-1;i++) cin >> L[i] >> R[i]; while(q--){ ll t,a,b,c,d; cin >> t >> a >> b >> c;a--; if (t==1){ L[a] = b; R[a] = c; }else{ c--; cin >> d; ll ans = 0; ll t = b; ll cur = a; if (c>a){ while(cur<c){ cur++; t++; if (t>R[cur-1]){ ans += t-R[cur-1]; t = R[cur-1]; } t = max(t,L[cur-1]+1); //cout << "at " << cur << ", t=" << t << "\n"; } }else{ while(cur>c){ cur--; t++; if (t>R[cur]){ ans += t-R[cur]; t = R[cur]; } t = max(t,L[cur]+1); //cout << "at " << cur << ", t=" << t << "\n"; } } if (t>d) ans += t-d; cout << ans << "\n"; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...