結果
問題 | No.43 野球の試合 |
ユーザー | 1235486527 |
提出日時 | 2019-12-23 16:54:52 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 242 ms / 5,000 ms |
コード長 | 870 bytes |
コンパイル時間 | 777 ms |
コンパイル使用メモリ | 11,912 KB |
実行使用メモリ | 10,220 KB |
最終ジャッジ日時 | 2023-10-17 17:30:33 |
合計ジャッジ時間 | 1,563 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
10,220 KB |
testcase_01 | AC | 30 ms
10,220 KB |
testcase_02 | AC | 30 ms
10,220 KB |
testcase_03 | AC | 29 ms
10,220 KB |
testcase_04 | AC | 30 ms
10,220 KB |
testcase_05 | AC | 29 ms
10,220 KB |
testcase_06 | AC | 30 ms
10,220 KB |
testcase_07 | AC | 242 ms
10,220 KB |
testcase_08 | AC | 29 ms
10,220 KB |
testcase_09 | AC | 29 ms
10,220 KB |
testcase_10 | AC | 29 ms
10,220 KB |
ソースコード
N = int(input()) tbd = [] win = [0] * N for i in range(N): for j, s in enumerate(input()): if s == 'o': win[i] += 1 elif s == '-': if not (j, i) in tbd: tbd.append((i, j)) n = len(tbd) ans = float('inf') if n != 0: for bm in range(1 << n): win_tmp = [0] * N for b in range(n): if bm & (1 << b) != 0: win_tmp[tbd[b][0]] += 1 else: win_tmp[tbd[b][1]] += 1 total_win = win[0] + win_tmp[0] tws = set([win[i] + win_tmp[i] for i in range(N)]) tmp = 1 for tw in tws: if total_win < tw: tmp += 1 ans = min(ans, tmp) else: tws = set([win[i] for i in range(N)]) tmp = 1 for tw in tws: if win[0] < tw: tmp += 1 ans = min(ans, tmp) print(ans)