結果
| 問題 |
No.43 野球の試合
|
| コンテスト | |
| ユーザー |
cherrypi59
|
| 提出日時 | 2018-10-03 07:24:20 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,050 bytes |
| コンパイル時間 | 517 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-10-12 10:11:55 |
| 合計ジャッジ時間 | 1,103 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 5 WA * 2 |
ソースコード
def cul(r):
res = 0
for i in r:
if i == "o":
res += 1
return res
def main():
n = int(input())
s = [list(input()) for i in range(n)]
score = [0] * n
for i in range(n):
if s[0][i] == "-":
s[0][i], s[i][0] = "o", "x"
score[0] = cul(s[0])
uncertain = []
for i in range(n):
for j in range(i+1, n):
if s[i][j] == "-":
uncertain.append((i, j))
ans = n
for i in range(2**len(uncertain)):
for j in range(len(uncertain)):
k, l = uncertain[j]
if (i >> j) & 1:
s[k][l], s[l][k] = "o", "x"
else:
s[k][l], s[l][k] = "x", "o"
cnt = 1
for j in range(n):
score[j] = cul(s[j])
if score[0] < score[j]:
cnt += 1
ans = min(ans, cnt)
for j in range(len(uncertain)):
k, l = uncertain[j]
s[k][l] = s[l][k] = "-"
print(ans)
if __name__ == '__main__':
main()
cherrypi59