結果

問題 No.2708 Jewel holder
ユーザー GOTKAKO
提出日時 2024-03-31 14:57:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 691 bytes
コンパイル時間 1,749 ms
コンパイル使用メモリ 196,940 KB
最終ジャッジ日時 2025-02-20 17:31:57
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int H,W; cin >> H >> W;
    vector<string> S(H);
    for(auto &s : S) cin >> s;

    int m = H+W-2,m2 = 1<<m,answer = 0;
    for(int i=0; i<m2; i++){
        vector<int> dr(m);
        int d = 0;
        for(int k=0; k<m; k++) if(i&(1<<k)) dr.at(k) = 1,d++;
        if(d != H-1) continue;
        int x = 0,y = 0,j = 1,ok = 1;
        for(int k=0; k<m; k++){
            if(dr.at(k)) x++;
            else y++;
            if(S.at(x).at(y) == '#') ok = 0;
            else if(S.at(x).at(y) == 'x') j--;
            else j++;
            if(j == -1) ok = 0;
        }
        if(ok) answer++;
    }
    cout << answer << endl;
}
0