답안 #499945

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
499945 2021-12-30T06:08:31 Z blue Bitaro, who Leaps through Time (JOI19_timeleap) C++17
0 / 100
53 ms 9064 KB
#include <iostream>
#include <vector>
#include <cassert>
using namespace std;

using ll = long long;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int N, Q;
    cin >> N >> Q;

    ll L[N+1], R[N+1];
    for(int i = 1; i <= N-1; i++) cin >> L[i] >> R[i];

    for(int j = 1; j <= Q; j++)
    {
        int T;
        cin >> T;

        if(T == 1)
        {
            ll P, S, E;
            cin >> P >> S >> E;

            L[P] = S;
            R[P] = E;
        }
        else
        {
            ll A, B, C, D;
            cin >> A >> B >> C >> D;

            ll ans = 0;

            if(A <= C)
            {
                ll x = B;
                int p = A;
                while(p != C)
                {
                    // cerr << "p = " << p << '\n';
                    if(L[p] <= x && x <= R[p]-1)
                    {
                        x++;
                        p++;
                    }
                    else if(x > R[p] - 1)
                    {
                        ans += x - (R[p] - 1);
                        x = R[p] - 1;
                    }
                    else if(x < L[p])
                    {
                        x = L[p];
                    }
                }

                ans += max(0LL, x-D);
            }
            else
            {
                ll x = B;
                int p = A;
                while(p != C)
                {
                    // cerr << "p = " << p << '\n';
                    if(L[p-1] <= x && x <= R[p-1]-1)
                    {
                        x++;
                        p--;
                    }
                    else if(x > R[p-1] - 1)
                    {
                        ans += x - (R[p-1] - 1);
                        x = R[p-1] - 1;
                    }
                    else if(x < L[p])
                    {
                        x = L[p-1];
                    }
                }

                ans += max(0LL, x-D);
            }

            cout << ans << '\n';
        }

        assert(0);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 53 ms 9064 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -