Submission #60977520


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

int main() {
    int h, w, x, y;
    cin >> h >> w >> x >> y;
    
    vector<vector<char>> a(h, vector<char>(w));
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    
    string t;
    cin >> t;
    
    int nowh = x - 1;
    int noww = y - 1;
    int house = 0;

    for (char move : t) {
        if (move == 'U' && a[nowh - 1][noww] != '#') {
            nowh -= 1;
            if (a[nowh][noww] == '@') {
                house++;
                a[nowh][noww] = '.';
            }
        } 
        if (move == 'D'  && a[nowh + 1][noww] != '#') {
            nowh += 1;
            if (a[nowh][noww] == '@') {
                house++;
                a[nowh][noww] = '.';
            }
        } 
        if (move == 'L' &&a[nowh][noww - 1] != '#') {
            noww -= 1;
            if (a[nowh][noww] == '@') {
                house++;
                a[nowh][noww] = '.';
            }
        } 
        if (move == 'R' && a[nowh][noww + 1] != '#') {
            noww += 1;
            if (a[nowh][noww] == '@') {
                house++;
                a[nowh][noww] = '.';
            }
        }
    }
    
    cout << nowh +1<< " " << noww +1 << " " << house << endl;
}

Submission Info

Submission Time
Task B - Santa Claus 1
User Rey564219
Language C++ 20 (gcc 12.2)
Score 200
Code Size 1354 Byte
Status AC
Exec Time 2 ms
Memory 3680 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 18
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, 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, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
hand_01.txt AC 1 ms 3560 KiB
hand_02.txt AC 1 ms 3480 KiB
random_01.txt AC 2 ms 3516 KiB
random_02.txt AC 1 ms 3488 KiB
random_03.txt AC 2 ms 3628 KiB
random_04.txt AC 1 ms 3496 KiB
random_05.txt AC 1 ms 3556 KiB
random_06.txt AC 1 ms 3552 KiB
random_07.txt AC 1 ms 3572 KiB
random_08.txt AC 1 ms 3484 KiB
random_09.txt AC 2 ms 3568 KiB
random_10.txt AC 1 ms 3536 KiB
random_11.txt AC 1 ms 3488 KiB
random_12.txt AC 1 ms 3484 KiB
random_13.txt AC 2 ms 3648 KiB
sample_01.txt AC 1 ms 3612 KiB
sample_02.txt AC 1 ms 3680 KiB
sample_03.txt AC 1 ms 3564 KiB