結果
| 問題 | No.2708 Jewel holder | 
| コンテスト | |
| ユーザー |  srjywrdnprkt | 
| 提出日時 | 2024-04-03 12:07:01 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 898 bytes | 
| コンパイル時間 | 1,869 ms | 
| コンパイル使用メモリ | 195,260 KB | 
| 最終ジャッジ日時 | 2025-02-20 19:50:24 | 
| ジャッジサーバーID (参考情報) | judge5 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int H, W, N, K, h=0, w=0, n, ans=0;
    bool f;
    cin >> H >> W;
    N = H+W-2;
    K = 1<<N;
    vector<string> s(H);
    for (int i=0; i<H; i++) cin >> s[i];
    for (int i=0; i<K; i++){
        if (__builtin_popcount(i) == H-1){
            h = 0; w = 0; n = 1; f = 1;
            for (int j=0; j<N; j++){
                if ((i>>j) & 1) h++;
                else w++;
                if (s[h][w] == '#'){
                    f = 0;
                    break;
                }
                else if (s[h][w] == 'o') n++;
                else n--;
                if (n < 0){
                    f = 0;
                    break;
                }
            }
            ans += f;
        }
    }
    cout << ans << endl;
    return 0;
}
            
            
            
        