제출 #1019737

#제출 시각아이디문제언어결과실행 시간메모리
1019737modwweBitaro, who Leaps through Time (JOI19_timeleap)C++17
4 / 100
3056 ms10504 KiB
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int Nmax=300010;
int N, Q, L[Nmax], R[Nmax];

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>N>>Q;
    for(int i=1; i<N; i++) cin>>L[i]>>R[i];
    while(Q--) {
        int op; cin>>op;
        if(op==1) {
            int k, l, r; cin>>k>>l>>r;
            L[k]=l, R[k]=r;
        }
        else {
            int s, x, e, y, ans=0;
            cin>>s>>x>>e>>y;
            if(s<e) {
                for(int i=s; i<e; i++) {
                    if(x<=L[i]) x=L[i]+1;
                    else if(x<R[i]) x++;
                    else ans+=x-(R[i]-1), x=R[i];
                }
                ans+=max(0ll, x-y);
            }
            else {
                for(int i=s-1; i>=e; i--) {
                    if(x<=L[i]) x=L[i]+1;
                    else if(x<R[i]) x++;
                    else ans+=x-(R[i]-1), x=R[i];
                }
                ans+=max(0ll, x-y);
            }
            cout<<ans<<"\n";
        }
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...