結果
| 問題 |
No.2708 Jewel holder
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-27 00:09:05 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 2,000 ms |
| コード長 | 975 bytes |
| コンパイル時間 | 3,646 ms |
| コンパイル使用メモリ | 281,592 KB |
| 実行使用メモリ | 7,324 KB |
| 最終ジャッジ日時 | 2025-03-27 00:09:11 |
| 合計ジャッジ時間 | 5,074 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i)
#define all(a) (a).begin(),(a).end()
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
int H, W;
cin >> H >> W;
vector<vector<char>> A(H, vector<char>(W));
rep(i, 0, H) rep(j, 0, W) cin >> A[i][j];
int N = H + W - 2;
vector<bool> perm(N, false);
rep(i, 0, W - 1) perm[N - i - 1] = true;
int ans = 0;
do {
int i = 0, j = 0;
bool can = true;
int cnt = 1;
rep(t, 0, N) {
if (perm[t]) ++j;
else ++i;
if (A[i][j] == '#') can = false;
else if (A[i][j] == 'o') ++cnt;
else {
--cnt;
if (cnt < 0) can = false;
}
}
if (can) ++ans;
} while (next_permutation(all(perm)));
cout << ans << '\n';
}