Submission #49113744


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

// bool in_mass(int x, int y, int w, int h)
// { return x >= 0 && y >= 0 && x < w && y < h; }

// const int dx[8] = {0, 0, -1, 1, 1, 1, -1, -1};
// const int dy[8] = {-1, 1, 0, 0, -1, 1, 1, -1};

int main() {
    int n, q;
    cin >> n >> q;

    map<int, pair<int, int>> m;

    for(int i = 0; i < n; i++) {
        m[-i] = {i + 1, 0};
    }

    int cnt = 0;
    for(int i = 0; i < q; i++) {
        int q1;
        cin >> q1;
        if(q1 == 1) {
            char q2;
            cin >> q2;
            pair<int, int> curr_head = m[cnt];
            cnt += 1;
            switch(q2) {
            case 'R':
                m[cnt] = {curr_head.first + 1, curr_head.second};
                break;
            case 'L':
                m[cnt] = {curr_head.first - 1, curr_head.second};
                break;
            case 'U':
                m[cnt] = {curr_head.first, curr_head.second + 1};
                break;
            case 'D':
                m[cnt] = {curr_head.first, curr_head.second - 1};
                break;
            default:
                break;
            }
        } else if(q1 == 2) {
            int q2;
            cin >> q2;
            q2 -= 1;
            cout << m[cnt - q2].first << " " << m[cnt - q2].second << endl;
        }
    }

    return 0;
}

Submission Info

Submission Time
Task C - Loong Tracking
User nnth_y
Language C++ 20 (gcc 12.2)
Score 300
Code Size 1396 Byte
Status AC
Exec Time 707 ms
Memory 77352 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 1
AC × 31
Set Name Test Cases
Sample sample_01.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, sample_01.txt
Case Name Status Exec Time Memory
random_01.txt AC 363 ms 77236 KiB
random_02.txt AC 139 ms 18400 KiB
random_03.txt AC 337 ms 75420 KiB
random_04.txt AC 195 ms 44316 KiB
random_05.txt AC 533 ms 72292 KiB
random_06.txt AC 508 ms 65732 KiB
random_07.txt AC 335 ms 68192 KiB
random_08.txt AC 93 ms 19032 KiB
random_09.txt AC 707 ms 67224 KiB
random_10.txt AC 498 ms 25624 KiB
random_11.txt AC 398 ms 66488 KiB
random_12.txt AC 190 ms 24088 KiB
random_13.txt AC 188 ms 9784 KiB
random_14.txt AC 1 ms 3484 KiB
random_15.txt AC 336 ms 77224 KiB
random_16.txt AC 338 ms 77232 KiB
random_17.txt AC 333 ms 77232 KiB
random_18.txt AC 346 ms 77352 KiB
random_19.txt AC 422 ms 72360 KiB
random_20.txt AC 415 ms 72204 KiB
random_21.txt AC 413 ms 72268 KiB
random_22.txt AC 434 ms 72408 KiB
random_23.txt AC 503 ms 67292 KiB
random_24.txt AC 485 ms 67232 KiB
random_25.txt AC 485 ms 67304 KiB
random_26.txt AC 514 ms 67348 KiB
random_27.txt AC 410 ms 72136 KiB
random_28.txt AC 405 ms 72288 KiB
random_29.txt AC 413 ms 72280 KiB
random_30.txt AC 429 ms 72424 KiB
sample_01.txt AC 1 ms 3492 KiB