結果

問題 No.43 野球の試合
ユーザー dangodango
提出日時 2023-07-09 16:19:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 115 ms / 5,000 ms
コード長 858 bytes
コンパイル時間 579 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 76,784 KB
最終ジャッジ日時 2023-09-30 19:41:21
合計ジャッジ時間 1,976 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
70,856 KB
testcase_01 AC 70 ms
70,896 KB
testcase_02 AC 70 ms
71,072 KB
testcase_03 AC 72 ms
71,056 KB
testcase_04 AC 83 ms
75,644 KB
testcase_05 AC 82 ms
76,004 KB
testcase_06 AC 95 ms
76,572 KB
testcase_07 AC 115 ms
76,784 KB
testcase_08 AC 92 ms
76,588 KB
testcase_09 AC 85 ms
76,044 KB
testcase_10 AC 90 ms
76,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    n = int(input())
    s = [input() for _ in range(n)]
    ans = n
    num = n * (n - 1) // 2
    for ii in range(2 ** num):
        id_ = ii
        cnt = [0] * n
        for i in range(n):
            for j in range(i + 1, n):
                result = "ox"[id_ % 2]
                id_ //= 2
                if s[i][j] != '-' and s[i][j] != result:
                    break
                cnt[i if result == 'o' else j] += 1
            else:
                continue
            break
        else:
            cnt0 = cnt[0]
            cnt.sort(reverse=True)
            rank = 1
            for i in range(n):
                if cnt[i] == cnt0:
                    ans = min(ans, rank)
                    break
                if cnt[i] != cnt[i + 1]:
                    rank += 1
    print(ans)

if __name__ == '__main__':
    main()
0