結果
| 問題 |
No.43 野球の試合
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-02 08:48:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 244 ms / 5,000 ms |
| コード長 | 887 bytes |
| コンパイル時間 | 247 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 77,924 KB |
| 最終ジャッジ日時 | 2024-12-02 08:48:36 |
| 合計ジャッジ時間 | 1,475 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 |
ソースコード
import copy
N = int(input())
S = [list(input()) for _ in range(N)]
A = []
for i in range(N-1):
for j in range(i+1,N):
if S[i][j]=="o" and S[j][i]=="-":
S[j][i] = "x"
elif S[i][j]=="x" and S[j][i]=="-":
S[j][i] = "o"
elif S[i][j]=="-" and S[j][i]=="o":
S[i][j] = "x"
elif S[i][j]=="-" and S[j][i]=="x":
S[i][j] = "o"
if S[i][j]=="-":
A.append((i,j))
ans = N
for i in range(1<<len(A)):
B = copy.deepcopy(S)
for j in range(len(A)):
y,x = A[j]
if (i>>j)&1:
B[y][x] = "o"
B[x][y] = "x"
else:
B[y][x] = "x"
B[x][y] = "o"
C = [0]*N
for k in range(N):
C[k] = B[k].count("o")
a = C[0]
C = sorted(list(set(C)),reverse=True)
cnt = C.index(a)+1
ans = min(ans,cnt)
print(ans)