Submission #74714890


Source Code Expand

#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
ll xor_upto(ll n) {
    if (n < 0) return 0;
    if (n % 4 == 0) return n;
    if (n % 4 == 1) return 1;
    if (n % 4 == 2) return n + 1;
    return 0;
}
ll get_range_xor(ll L, ll R, ll C) {
    if (C == 0) return 0;
    ll res = 0;
    
    for (ll i = L; i <= R; ++i) {
        res ^= (i * C);
    }
    return res;
}

void solve() {
    int N;
    ll M;
    if (!(cin >> N >> M)) return;
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    ll total_xor = 0;
    ll k = 1;

    while (k <= M) {
        ll current_f = 0;
        ll current_rem = k;
        ll slack = M - k + 1; 

        for (int i = 0; i < N; ++i) {
            if (current_rem >= A[i]) {
                current_rem -= A[i];
                current_f += A[i];
            } else {
                slack = min(slack, A[i] - current_rem - 1);
            }
        }

        ll L = k;
        ll R = k + slack;
        R = min(R, M);
        total_xor ^= get_range_xor(L, R, current_f);

        k = R + 1;
    }
    cout << total_xor << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int T;
    cin >> T;
    while (T--) solve();
    return 0;
}

Submission Info

Submission Time
Task D - Greedy Customer
User karishma_26
Language C++23 (GCC 15.2.0)
Score 0
Code Size 1318 Byte
Status TLE
Exec Time > 2000 ms
Memory 7196 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 1
AC × 6
TLE × 75
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 01_handmade_09.txt, 01_handmade_10.txt, 01_handmade_11.txt, 01_handmade_12.txt, 01_handmade_13.txt, 01_handmade_14.txt, 01_handmade_15.txt, 01_handmade_16.txt, 01_handmade_17.txt, 01_handmade_18.txt, 01_handmade_19.txt, 01_handmade_20.txt, 01_handmade_21.txt, 01_handmade_22.txt, 01_handmade_23.txt, 01_handmade_24.txt, 01_handmade_25.txt, 01_handmade_26.txt, 01_handmade_27.txt, 01_handmade_28.txt, 01_handmade_29.txt, 01_handmade_30.txt, 01_handmade_31.txt, 01_handmade_32.txt, 01_handmade_33.txt, 01_handmade_34.txt, 01_handmade_35.txt, 01_handmade_36.txt, 01_handmade_37.txt, 01_handmade_38.txt, 01_handmade_39.txt, 01_handmade_40.txt, 01_handmade_41.txt, 01_handmade_42.txt, 01_handmade_43.txt, 01_handmade_44.txt, 01_handmade_45.txt, 01_handmade_46.txt, 01_handmade_47.txt, 01_handmade_48.txt, 01_handmade_49.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt, 02_random_17.txt, 02_random_18.txt, 02_random_19.txt, 02_random_20.txt, 02_random_21.txt, 02_random_22.txt, 02_random_23.txt, 02_random_24.txt, 02_random_25.txt, 02_random_26.txt, 02_random_27.txt, 02_random_28.txt, 02_random_29.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3452 KiB
01_handmade_00.txt TLE > 2000 ms 7196 KiB
01_handmade_01.txt AC 19 ms 7196 KiB
01_handmade_02.txt AC 59 ms 3580 KiB
01_handmade_03.txt TLE > 2000 ms 3312 KiB
01_handmade_04.txt AC 1 ms 3520 KiB
01_handmade_05.txt TLE > 2000 ms 7000 KiB
01_handmade_06.txt TLE > 2000 ms 7076 KiB
01_handmade_07.txt TLE > 2000 ms 7108 KiB
01_handmade_08.txt TLE > 2000 ms 7000 KiB
01_handmade_09.txt TLE > 2000 ms 7096 KiB
01_handmade_10.txt TLE > 2000 ms 7172 KiB
01_handmade_11.txt TLE > 2000 ms 7000 KiB
01_handmade_12.txt AC 59 ms 3580 KiB
01_handmade_13.txt TLE > 2000 ms 3252 KiB
01_handmade_14.txt TLE > 2000 ms 7152 KiB
01_handmade_15.txt TLE > 2000 ms 7152 KiB
01_handmade_16.txt TLE > 2000 ms 7152 KiB
01_handmade_17.txt TLE > 2000 ms 7096 KiB
01_handmade_18.txt TLE > 2000 ms 7052 KiB
01_handmade_19.txt TLE > 2000 ms 7152 KiB
01_handmade_20.txt TLE > 2000 ms 7116 KiB
01_handmade_21.txt TLE > 2000 ms 7092 KiB
01_handmade_22.txt TLE > 2000 ms 7052 KiB
01_handmade_23.txt TLE > 2000 ms 7156 KiB
01_handmade_24.txt TLE > 2000 ms 7052 KiB
01_handmade_25.txt TLE > 2000 ms 7092 KiB
01_handmade_26.txt TLE > 2000 ms 7144 KiB
01_handmade_27.txt TLE > 2000 ms 7096 KiB
01_handmade_28.txt TLE > 2000 ms 7152 KiB
01_handmade_29.txt TLE > 2000 ms 7176 KiB
01_handmade_30.txt TLE > 2000 ms 7172 KiB
01_handmade_31.txt TLE > 2000 ms 7152 KiB
01_handmade_32.txt TLE > 2000 ms 7008 KiB
01_handmade_33.txt TLE > 2000 ms 6996 KiB
01_handmade_34.txt TLE > 2000 ms 7052 KiB
01_handmade_35.txt TLE > 2000 ms 6996 KiB
01_handmade_36.txt TLE > 2000 ms 7176 KiB
01_handmade_37.txt TLE > 2000 ms 7000 KiB
01_handmade_38.txt TLE > 2000 ms 7092 KiB
01_handmade_39.txt TLE > 2000 ms 7092 KiB
01_handmade_40.txt TLE > 2000 ms 7176 KiB
01_handmade_41.txt TLE > 2000 ms 7076 KiB
01_handmade_42.txt TLE > 2000 ms 7156 KiB
01_handmade_43.txt TLE > 2000 ms 7152 KiB
01_handmade_44.txt TLE > 2000 ms 7132 KiB
01_handmade_45.txt TLE > 2000 ms 7144 KiB
01_handmade_46.txt TLE > 2000 ms 6984 KiB
01_handmade_47.txt TLE > 2000 ms 7116 KiB
01_handmade_48.txt TLE > 2000 ms 7148 KiB
01_handmade_49.txt TLE > 2000 ms 7008 KiB
02_random_00.txt TLE > 2000 ms 3720 KiB
02_random_01.txt TLE > 2000 ms 3864 KiB
02_random_02.txt TLE > 2000 ms 3560 KiB
02_random_03.txt TLE > 2000 ms 3592 KiB
02_random_04.txt TLE > 2000 ms 4616 KiB
02_random_05.txt TLE > 2000 ms 4300 KiB
02_random_06.txt TLE > 2000 ms 4336 KiB
02_random_07.txt TLE > 2000 ms 3924 KiB
02_random_08.txt TLE > 2000 ms 6888 KiB
02_random_09.txt TLE > 2000 ms 4484 KiB
02_random_10.txt TLE > 2000 ms 4664 KiB
02_random_11.txt TLE > 2000 ms 5280 KiB
02_random_12.txt TLE > 2000 ms 6412 KiB
02_random_13.txt AC 67 ms 3748 KiB
02_random_14.txt TLE > 2000 ms 5924 KiB
02_random_15.txt TLE > 2000 ms 4684 KiB
02_random_16.txt TLE > 2000 ms 5204 KiB
02_random_17.txt TLE > 2000 ms 5892 KiB
02_random_18.txt TLE > 2000 ms 4516 KiB
02_random_19.txt TLE > 2000 ms 5196 KiB
02_random_20.txt TLE > 2000 ms 6996 KiB
02_random_21.txt TLE > 2000 ms 7144 KiB
02_random_22.txt TLE > 2000 ms 7116 KiB
02_random_23.txt TLE > 2000 ms 7044 KiB
02_random_24.txt TLE > 2000 ms 7052 KiB
02_random_25.txt TLE > 2000 ms 3924 KiB
02_random_26.txt TLE > 2000 ms 3504 KiB
02_random_27.txt TLE > 2000 ms 7092 KiB
02_random_28.txt TLE > 2000 ms 7052 KiB
02_random_29.txt TLE > 2000 ms 7172 KiB