Submission #61811572


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
#ifdef LOCAL
freopen("in.txt", "r", stdin);
freopen("ou.txt", "w", stdout);
#endif
int q; cin >> q;
deque<pair<int, int>> dq;
int offset = 0;
for (int i=0, tp, l, k; i<q; i++) {
cin >> tp;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;

#define int long long

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("ou.txt", "w", stdout);
    #endif

    int q; cin >> q;

    deque<pair<int, int>> dq;
    int offset = 0;

    for (int i=0, tp, l, k; i<q; i++) {
        cin >> tp;
        if (tp == 1) {
            cin >> l;
            if (dq.empty()) dq.push_back({0, l});
            else {
                auto [last_head, last_length] = dq.back(); 
                dq.push_back({last_head + last_length, l});
            }
        } else if (tp == 2) {
            int first_length = dq.front().second;
            offset += first_length;
            dq.pop_front();
        } else {
            cin >> k;
            k--;
            int kth = dq[k].first;
            cout << kth - offset << "\n";
        }
    }

    return 0;
}

Submission Info

Submission Time
Task C - Snake Queue
User qqcovid
Language C++ 20 (gcc 12.2)
Score 300
Code Size 1005 Byte
Status AC
Exec Time 38 ms
Memory 8056 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 33
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 02_min_00.txt, 02_min_01.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3420 KB
00_sample_01.txt AC 1 ms 3388 KB
00_sample_02.txt AC 1 ms 3424 KB
01_test_00.txt AC 1 ms 3412 KB
01_test_01.txt AC 1 ms 3492 KB
01_test_02.txt AC 1 ms 3352 KB
01_test_03.txt AC 1 ms 3508 KB
01_test_04.txt AC 1 ms 3480 KB
01_test_05.txt AC 1 ms 3644 KB
01_test_06.txt AC 34 ms 4396 KB
01_test_07.txt AC 17 ms 4032 KB
01_test_08.txt AC 34 ms 4520 KB
01_test_09.txt AC 30 ms 4204 KB
01_test_10.txt AC 34 ms 4380 KB
01_test_11.txt AC 14 ms 3764 KB
01_test_12.txt AC 34 ms 4420 KB
01_test_13.txt AC 13 ms 3788 KB
01_test_14.txt AC 34 ms 4372 KB
01_test_15.txt AC 27 ms 4592 KB
01_test_16.txt AC 25 ms 4572 KB
01_test_17.txt AC 24 ms 4628 KB
01_test_18.txt AC 28 ms 5708 KB
01_test_19.txt AC 26 ms 5684 KB
01_test_20.txt AC 26 ms 5680 KB
01_test_21.txt AC 25 ms 5700 KB
01_test_22.txt AC 33 ms 5424 KB
01_test_23.txt AC 38 ms 5520 KB
01_test_24.txt AC 27 ms 8028 KB
01_test_25.txt AC 19 ms 8012 KB
01_test_26.txt AC 27 ms 8056 KB
01_test_27.txt AC 17 ms 3428 KB
02_min_00.txt AC 1 ms 3468 KB
02_min_01.txt AC 1 ms 3484 KB


2025-02-28 (Fri)
11:19:32 +00:00