結果

問題 No.2708 Jewel holder
ユーザー mnmmnm
提出日時 2024-04-05 21:14:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,247 bytes
コンパイル時間 963 ms
コンパイル使用メモリ 100,028 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-05 21:14:19
合計ジャッジ時間 1,722 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 1 ms
6,676 KB
testcase_10 AC 1 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 1 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'void dfs(int, int, int)':
main.cpp:68:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17' [-Wc++17-extensions]
   68 |     for(auto [di, dj] : vector<pair<int, int>>{{1, 0}, {0, 1}}) {
      |              ^

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

#define rep(i, n) for(i = 0; i < n; ++i)
#define inc_rep(i, a, n) for(i = a; i <= n; ++i)
#define dec_rep(i, n, a) for(i = n; i >= a; --i)
#define in(a) cin >> a
#define out(a, b) cout << a << b
#define print_vec(v)                              \
    for(auto it = v.begin(); it != v.end(); ++it) \
        cout << *it << " ";                       \
    cout << endl
#define print_vec2d(v)                       \
    for(int i = 0; i < v.size(); ++i) {      \
        for(int j = 0; j < v[i].size(); ++j) \
            cout << v[i][j] << " ";          \
        cout << endl;                        \
    }                                        \
    cout << endl
#define print_vecpair(v)              \
    for(int i = 0; i < v.size(); ++i) \
    cout << v[i].first << " " << v[i].second << endl
#define vin(v)                        \
    for(int i = 0; i < v.size(); ++i) \
    cin >> v[i]
#define v2din(v)                             \
    for(int i = 0; i < v.size(); ++i) {      \
        for(int j = 0; j < v[i].size(); ++j) \
            cin >> v[i][j];                  \
    }
#define vpairin(v)                      \
    for(int i = 0; i < v.size(); ++i) { \
        int a, b;                       \
        cin >> a >> b;                  \
        v[i] = make_pair(a, b);         \
    }
using namespace std;
using lint = long long;
using ull = unsigned long long;

int cnt = 0;
int h, w;
vector<string> vs;

void dfs(int i, int j, int jwl) {
    if(vs[i][j] == 'o') { jwl++; }
    else if(vs[i][j] == 'x') {
        jwl--;
        if(jwl < 0) { return; }
    }

    if(i == h - 1 && j == w - 1 && jwl >= 0) {
        cnt++;
        return;
    }

    for(auto [di, dj] : vector<pair<int, int>>{{1, 0}, {0, 1}}) {
        int ni = i + di, nj = j + dj;
        if(ni < h && nj < w && vs[ni][nj] != '#') {
            dfs(ni, nj, jwl);
        }
    }
    return;
}

int main(void) {
    cin >> h >> w;
    vs.resize(h);
    vin(vs);

    dfs(0, 0, 0);

    cout << cnt << "\n";

    return 0;
}
0