結果
問題 | No.43 野球の試合 |
ユーザー | maspy |
提出日時 | 2020-02-02 12:26:01 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 1,322 ms / 5,000 ms |
コード長 | 840 bytes |
コンパイル時間 | 122 ms |
コンパイル使用メモリ | 11,952 KB |
実行使用メモリ | 42,620 KB |
最終ジャッジ日時 | 2023-10-19 00:39:50 |
合計ジャッジ時間 | 7,812 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 497 ms
42,620 KB |
testcase_01 | AC | 507 ms
42,360 KB |
testcase_02 | AC | 510 ms
42,620 KB |
testcase_03 | AC | 501 ms
42,620 KB |
testcase_04 | AC | 499 ms
42,524 KB |
testcase_05 | AC | 497 ms
42,420 KB |
testcase_06 | AC | 495 ms
42,620 KB |
testcase_07 | AC | 1,322 ms
42,620 KB |
testcase_08 | AC | 499 ms
42,420 KB |
testcase_09 | AC | 510 ms
42,524 KB |
testcase_10 | AC | 527 ms
42,620 KB |
ソースコード
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np import itertools N = int(readline()) A = np.frombuffer(read(),'S1').reshape(N,-1)[:,:N] base = np.zeros((N,N),np.int32) base[A == b'#'] = 0 base[A == b'-'] = 0 base[A == b'o'] = 1 base[A == b'x'] = -1 base.flags.writeable = False match = [] for i,j in itertools.combinations(range(N),2): if base[i][j] == 0: match.append((i,j)) n_match = len(match) best = N for p in itertools.product((True,False),repeat=n_match): A = base.copy() for (i,j),bl in zip(match, p): if not bl: i,j = j,i A[i,j] = 1 A[j,i] = -1 pts = A.sum(axis=1) me = pts[0] rank = len(np.unique(pts[pts > me])) + 1 if best > rank: best = rank print(best)