結果
問題 | No.2708 Jewel holder |
ユーザー |
![]() |
提出日時 | 2024-03-31 13:44:52 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 969 bytes |
コンパイル時間 | 2,216 ms |
コンパイル使用メモリ | 205,760 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-09-30 18:19:56 |
合計ジャッジ時間 | 2,990 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
import std, core.bitop; bool chmin(T)(ref T SE, T MI) { if (SE > MI) { SE = MI; return true; } else { return false; } } bool chmax(T)(ref T SE, T MI) { if (SE < MI) { SE = MI; return true; } else { return false; } } int lowerBound(T)(T[] SE, T MI) { int lo = -1, hi = cast(int)(SE.length); while (hi - lo > 1) { int mid = lo + hi >> 1; (SE[mid] < MI ? lo : hi) = mid; } return hi; } int upperBound(T)(T[] SE, T MI) { int lo = -1, hi = cast(int)(SE.length); while (hi - lo > 1) { int mid = lo + hi >> 1; (SE[mid] > MI ? hi : lo) = mid; } return hi; } void main() { int H, W; readf("%s %s\n", H, W); string[] A; foreach (i; 0 .. H) { A ~= readln.chomp; } int ans; foreach (i; 0 .. 1 << H + W - 2) { if (popcnt(i) == H - 1) { bool ok = true; int X, Y; int cnt = 1; foreach (j; 0 .. H + W - 2) { ++(i >> j & 1 ? X : Y); cnt += (A[X][Y] == 'o' ? 1 : -1); ok &= A[X][Y] != '#'; ok &= cnt >= 0; } ans += ok; } } ans.writeln; }