結果

問題 No.2708 Jewel holder
ユーザー Iroha_3856Iroha_3856
提出日時 2024-03-31 13:41:30
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 4,718 bytes
コンパイル時間 5,824 ms
コンパイル使用メモリ 331,560 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-09-30 18:14:53
合計ジャッジ時間 6,424 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 1 ms
5,248 KB
testcase_04 AC 1 ms
5,248 KB
testcase_05 AC 2 ms
5,248 KB
testcase_06 AC 2 ms
5,248 KB
testcase_07 AC 1 ms
5,248 KB
testcase_08 AC 2 ms
5,248 KB
testcase_09 AC 2 ms
5,248 KB
testcase_10 AC 2 ms
5,248 KB
testcase_11 AC 2 ms
5,248 KB
testcase_12 AC 1 ms
5,248 KB
testcase_13 AC 2 ms
5,248 KB
testcase_14 AC 2 ms
5,248 KB
testcase_15 AC 1 ms
5,248 KB
testcase_16 AC 2 ms
5,248 KB
testcase_17 AC 2 ms
5,248 KB
testcase_18 AC 1 ms
5,248 KB
testcase_19 AC 2 ms
5,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//AtCoder-Library
#if __has_include(<atcoder/all>)
#include<atcoder/all>
using namespace atcoder;
using mint = atcoder::modint998244353;
#endif

//PBDS-tree
#if __has_include(<ext/pb_ds/assoc_container.hpp>)
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//tree.find_by_order(k) = tree[k] (0-indexed)
//tree.order_of_key(k) = tree.lower_bound(k) - tree.begin()
//Note: Can only be used for non-multiple sets.
#endif

#define vec vector
#define ll long long
#define ull unsigned long long
#define vi vec<int>
#define vll vec<ll>
#define vb vec<bool>
#define vvi vec<vi>
#define vvll vec<vll>
#define vvb vec<vb>
#define vvvi vec<vvi>
#define vvvll vec<vvll>
#define vvvb vec<vvb>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define pq priority_queue
template<class T> using spq = priority_queue<T, vector<T>, greater<T>>;
#define eb emplace_back
#define pb push_back
#define spa " "

#define all(x) (x).begin(), (x).end()
#define rep(i, l, r) for (int i=(int)(l); i<(int)(r); i++)
#define REP(i, l, r) for (int i=(int)(l); i<=(int)(r); i++)
#define siz(x) (int)x.size()

template<class T>bool chmax(T &a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, T b) { if (b<a) { a=b; return 1; } return 0; }

//Slice(A, l, r) = A[l, r)
template<class T>
vector<T> Slice(vector<T> A, int l, int r) {
    assert(0 <= l && l < (int)A.size());
    assert(0 <= r && r <= (int)A.size());
    vector<T> ret;
    for (int i = l; i<r; i++) ret.push_back(A[i]);
    return ret;
}

//Slice(S, l, r) = S[l, r)
string Slice(string s, int l, int r) {
    assert(0 <= l && l < (int)s.size());
    assert(0 <= r && r <= (int)s.size());
    string ret;
    for (int i = l; i<r; i++) ret += s[i];
    return ret;
}

ll Ceil(ll x, ll y) {
    assert(y != 0);
    if ((x >= 0) == (y >= 0)) {
        return (abs(x) + abs(y)-1)/abs(y);
    }
    else {
        return -(abs(x)/abs(y));
    }
}

ll Floor(ll x, ll y) {
    assert(y != 0);
    if ((x >= 0) == (y >= 0)) {
        return abs(x)/abs(y);
    }
    else {
        return -((abs(x) + abs(y)-1)/abs(y));
    }
}

template<class T, class U> 
istream &operator>>(istream &is, pair<T, U> &p) {
    is >> p.first >> p.second;
    return is;
}

template<class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << p.first << " " << p.second;
    return os;
}

template <class T>
istream &operator>>(istream &is, vector<T> &v) {
    for(auto &x : v) {
        is >> x;
    }
    return is;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for(int i = 0; i < (int)v.size(); i++) {
        if(i != (int)v.size() - 1)
            os << v[i] << " ";
        else
            os << v[i];
    }
    return os;
}

template<class T>
void print(T A, bool f = true) {
    cerr << A;
    if (f) cerr << endl;
}

template<class T, class U>
void print(pair<T, U> A, bool f = true) {
    cerr << "{" << A.first << ", " << A.second << "}";
    if (f) cerr << endl;
}

template<class T> 
void print(vector<T> A, bool f = true) {
    cerr << "{";
    for (int i = 0; i<(int)A.size(); i++) {
        print(A[i], false);
        if (i+1 != (int)A.size()) cerr << ", ";
    }
    cerr << "}";
    if (f) cerr << endl;
}

#define debug(x) cerr << #x << " = "; print(x)
#define debug2(x) cerr << #x << " = "; print(x, false)

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        cerr << fixed << setprecision(15);
    }
} iosetup;

struct Edge {
    int to;
    int cost;
    Edge(int to, int cost) : to(to), cost(cost) {}
};

const int mod1 = 998244353;
const int mod2 = 1000000007;
const int inf = 1000010000;
const ll INF = 1LL<<60;

int H, W;
vector<string> S;

int ans = 0;

void dfs(int r, int c, int p) {
    if (r == H-1 && c == W-1) {
        ans++;
        return;
    } 
    if (r < H-1) {
        if (S[r+1][c] == 'o') dfs(r+1, c, p + 1);
        if (S[r+1][c] == '#') ;
        if (S[r+1][c] == 'x') {
            if (p == 0) ;
            else dfs(r+1, c, p-1);
        } 
    }
    if (c < W-1) {
        if (S[r][c+1] == 'o') dfs(r, c+1, p + 1);
        if (S[r][c+1] == '#') ;
        if (S[r][c+1] == 'x') {
            if (p == 0) ;
            else dfs(r, c+1, p-1);
        } 
    }
}

int main() {
    cin >> H >> W;
    S.resize(H); rep(i, 0, H) cin >> S[i];
    dfs(0, 0, 1);
    cout << ans << endl;
}
0