Submission #1006408

#TimeUsernameProblemLanguageResultExecution timeMemory
1006408AdamGSBitaro, who Leaps through Time (JOI19_timeleap)C++17
4 / 100
3068 ms4948 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(a, b) for(int a = 0; a < (b); ++a) #define st first #define nd second #define pb push_back #define all(a) a.begin(), a.end() const int LIM=3e5+7; ll A[LIM], B[LIM]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, q; cin >> n >> q; rep(i, n-1) { cin >> A[i] >> B[i]; --B[i]; } while(q--) { ll t, a, b, c, d; cin >> t; if(t==1) { cin >> a >> b >> c; --a; A[a]=b; B[a]=c-1; continue; } cin >> a >> b >> c >> d; --a; --c; ll ans=0; while(a<c) { if(b<=A[a]) { b=A[a]+1; ++a; continue; } if(b>B[a]) { ans+=b-B[a]; b=B[a]+1; ++a; continue; } ++b; ++a; } while(a>c) { --a; if(b<=A[a]) { b=A[a]+1; continue; } if(b>B[a]) { ans+=b-B[a]; b=B[a]+1; continue; } ++b; } if(b>d) ans+=b-d; cout << ans << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...