Submission #499958

# Submission time Handle Problem Language Result Execution time Memory
499958 2021-12-30T06:22:25 Z blue Bitaro, who Leaps through Time (JOI19_timeleap) C++17
0 / 100
3000 ms 4708 KB
#include <iostream>
#include <vector>
#include <cassert>
#include <cstdio>
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], R[N];
    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)
            {
                // cerr << "case R\n";
                ll x = B;
                int p = A;

                for(int p = A; p < C; p++)
                {
                    if(L[p] <= x && x <= R[p])
                    {
                        x++;
                        ans += 0;
                    }
                    else if(x < L[p])
                    {
                        x += (L[p] - x) + 1;
                        ans += 0;
                    }
                    else if(x > R[p] - 1)
                    {
                        ans += x - (R[p] - 1);
                        x = R[p];
                    }
                }

                ans += max(0LL, x-D);
            }
            else
            {
                // cerr << "case L\n";
                ll x = B;
                int p = A;

                for(int p = A; p > C; p--)
                {
                    // cerr << "currently at position " << p << " at time " << x << '\n';
                    if(L[p-1] <= x && x <= R[p-1])
                    {
                        x++;
                        ans += 0;
                    }
                    else if(x < L[p-1])
                    {
                        x += (L[p-1] - x) + 1;
                        ans += 0;
                    }
                    else if(x > R[p-1] - 1)
                    {
                        ans += x - (R[p-1] - 1);
                        x = R[p-1];
                    }
                }

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

            cout << ans << '\n';
            // cout << ans << '\n';

            // if(j >= 1) assert(0);
        }
    }
}

Compilation message

timeleap.cpp: In function 'int main()':
timeleap.cpp:44:21: warning: unused variable 'p' [-Wunused-variable]
   44 |                 int p = A;
      |                     ^
timeleap.cpp:71:21: warning: unused variable 'p' [-Wunused-variable]
   71 |                 int p = A;
      |                     ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 372 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 2 ms 324 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 3 ms 324 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Incorrect 2 ms 332 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3067 ms 4708 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 308 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 372 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 2 ms 324 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 3 ms 324 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Incorrect 2 ms 332 KB Output isn't correct
22 Halted 0 ms 0 KB -