提出 #60953244


ソースコード 拡げる

#include <bits/stdc++.h>
using namespace std;
int64_t inf = (int64_t)1e+18;
int64_t mod = 1000000007;

// @author: ZhockDen

void runCase(int64_t &testCase) {
    // cout << "#Case " << testCase << ": \n";

    int64_t h, w, x, y;
    cin >> h >> w >> x >> y;
    x--, y--;
    vector<vector<int64_t>> grid(h, vector<int64_t>(w, 0));
    for (int64_t i = 0; i < h; i++) {
        string s;
        cin >> s;
        for (int64_t j = 0; j < w; j++) {
            if (s[j] == '#') grid[i][j] = -1;
            if (s[j] == '@') grid[i][j] = 1;
        }
    }
    string T;
    cin >> T;
    vector<vector<int64_t>> vis(h, vector<int64_t>(w, 0));
    int64_t ans = 0;
    if (grid[x][y] == 1) vis[x][y] = 1;
    for (int64_t i = 0; i < T.size(); i++) {
        if (T[i] == 'U') {
            if (x - 1 >= 0 && grid[x - 1][y] >= 0) x -= 1;
        } else if (T[i] == 'D') {
            if (x + 1 < h && grid[x + 1][y] >= 0) x += 1;
        } else if (T[i] == 'L') {
            if (y - 1 >= 0 && grid[x][y - 1] >= 0) y -= 1;
        } else if (T[i] == 'R') {
            if (y + 1 < w && grid[x][y + 1] >= 0) y += 1;
        }
        if (grid[x][y] == 1) vis[x][y] = 1;
    }
    for (auto &v : vis) {
        for (auto &e : v) ans += e;
    }
    cout << x + 1 << " " << y + 1 << " " << ans << "\n";
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0);

    int64_t tests = 1;
    // cin >> tests;
    for (int64_t i = 1; i <= tests; i++) runCase(i);

    return 0;
}

提出情報

提出日時
問題 B - Santa Claus 1
ユーザ abhaysingh05
言語 C++ 20 (gcc 12.2)
得点 200
コード長 1537 Byte
結果 AC
実行時間 1 ms
メモリ 3604 KiB

コンパイルエラー

Main.cpp: In function ‘void runCase(int64_t&)’:
Main.cpp:28:27: warning: comparison of integer expressions of different signedness: ‘int64_t’ {aka ‘long int’} and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   28 |     for (int64_t i = 0; i < T.size(); i++) {
      |                         ~~^~~~~~~~~~
Main.cpp:8:23: warning: unused parameter ‘testCase’ [-Wunused-parameter]
    8 | void runCase(int64_t &testCase) {
      |              ~~~~~~~~~^~~~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 3
AC × 18
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
hand_01.txt AC 1 ms 3508 KiB
hand_02.txt AC 1 ms 3472 KiB
random_01.txt AC 1 ms 3596 KiB
random_02.txt AC 1 ms 3420 KiB
random_03.txt AC 1 ms 3516 KiB
random_04.txt AC 1 ms 3560 KiB
random_05.txt AC 1 ms 3600 KiB
random_06.txt AC 1 ms 3468 KiB
random_07.txt AC 1 ms 3488 KiB
random_08.txt AC 1 ms 3456 KiB
random_09.txt AC 1 ms 3596 KiB
random_10.txt AC 1 ms 3468 KiB
random_11.txt AC 1 ms 3528 KiB
random_12.txt AC 1 ms 3488 KiB
random_13.txt AC 1 ms 3604 KiB
sample_01.txt AC 1 ms 3424 KiB
sample_02.txt AC 1 ms 3472 KiB
sample_03.txt AC 1 ms 3488 KiB