結果

問題 No.2708 Jewel holder
ユーザー Today03Today03
提出日時 2024-03-31 20:12:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,104 bytes
コンパイル時間 2,197 ms
コンパイル使用メモリ 205,744 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 20:12:37
合計ジャッジ時間 2,980 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_04 AC 2 ms
6,676 KB
testcase_05 WA -
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 WA -
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#ifdef LOCAL
#include "./debug.cpp"
#else
#define debug(...)
#define print_line
#endif
using namespace std;
using ll = long long;

int main() {
    int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for (int i = 0; i < H; i++) {
        cin >> S[i];
    }

    vector<int> T(H + W - 2, 0);
    for (int i = H - 1; i < H + W - 2; i++) {
        T[i] = 1;
    }

    int ans = 0;
    do {
        int cnt = 0, x = 0, y = 0;
        bool ok = true;
        for (int i = 0; i < H + W - 2; i++) {
            if (x >= H || y >= H || S[x][y] == '#') {
                ok = false;
                break;
            }
            if (S[x][y] == 'o') {
                cnt++;
            } else if (S[x][y] == 'x' && cnt > 0) {
                cnt--;
            } else {
                ok = false;
                break;
            }
            if (T[i] == 0) {
                x++;
            } else {
                y++;
            }
        }
        if (ok) {
            ans++;
        }
    } while (next_permutation(T.begin(), T.end()));

    cout << ans << endl;
}
0