結果
問題 | No.43 野球の試合 |
ユーザー | roaris |
提出日時 | 2019-08-02 17:26:58 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 229 ms / 5,000 ms |
コード長 | 936 bytes |
コンパイル時間 | 80 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-07-05 08:10:25 |
合計ジャッジ時間 | 1,028 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 |
ソースコード
N = int(input()) s = [input() for _ in range(N)] win_num = {i: 0 for i in range(N)} unmatch = [] for i in range(N): for j in range(i+1, N): if s[i][j] == 'o': win_num[i] += 1 elif s[i][j] == 'x': win_num[j] += 1 else: unmatch.append((i, j)) l = len(unmatch) if l == 0: for i, value in enumerate(sorted(list(set(win_num.values())), reverse=True), 1): if win_num[0] == value: print(i) exit() ans = 10 ** 18 for i in range(2 ** l): win_num_copy = win_num.copy() for j in range(l): if (i >> j) & 1: win_num_copy[unmatch[j][0]] += 1 else: win_num_copy[unmatch[j][1]] += 1 for i, value in enumerate(sorted(list(set(win_num_copy.values())), reverse=True), 1): if win_num_copy[0] == value: ans_cand = i ans = min(ans, ans_cand) print(ans)