結果

問題 No.43 野球の試合
ユーザー momoyuumomoyuu
提出日時 2022-08-03 00:44:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 131 ms / 5,000 ms
コード長 1,109 bytes
コンパイル時間 1,314 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 77,700 KB
最終ジャッジ日時 2023-10-01 01:22:48
合計ジャッジ時間 2,742 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,192 KB
testcase_01 AC 73 ms
71,296 KB
testcase_02 AC 72 ms
71,380 KB
testcase_03 AC 73 ms
71,384 KB
testcase_04 AC 80 ms
75,156 KB
testcase_05 AC 92 ms
76,564 KB
testcase_06 AC 131 ms
77,700 KB
testcase_07 AC 73 ms
71,352 KB
testcase_08 AC 100 ms
77,260 KB
testcase_09 AC 94 ms
77,196 KB
testcase_10 AC 122 ms
77,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = [list(input()) for _ in range(N)]
l = [i for i in range(N)]
from itertools import combinations
l = combinations(l,2)
l = list(l)

all = N*(N-1)//2
now = N
for s in range(2**all):
    d = [0 for _ in range(N)]
    pi = True
    for i in range(all):
        p,q = l[i]
        w = 0
        if S[p][q]  == "-":
            if s>>i & 1:
                w = 0
            else:
                w = 1
        elif (S[p][q] == "o" and s>>i & 1) or (S[p][q] == "x" and s>>i & 1 == 0):
            if S[p][q] == "o":
                w = 0
            else:
                w = 1
        else:
            pi = False
            break
        if w == 0:
            d[p] += 1
        else:
            d[q] += 1
    if not pi:
        continue
    ll = []
    for i in range(len(d)):
        ll.append((d[i],i))
    ll.sort(key=lambda x:(-x[0],x[1]))
    a = ll[0][0]
    b = 1
    if ll[0][1] == 0:
        now = 1
        break
    for i in range(1,N):
        if ll[i-1][0] != ll[i][0]:
            b += 1
        if ll[i][1] == 0:
            now = min(now,b)
            break

print(now)



0