結果
問題 | No.43 野球の試合 |
ユーザー | Coki628 |
提出日時 | 2020-06-04 00:29:35 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 564 ms / 5,000 ms |
コード長 | 1,732 bytes |
コンパイル時間 | 72 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-11-26 11:20:05 |
合計ジャッジ時間 | 2,844 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
11,008 KB |
testcase_01 | AC | 27 ms
11,008 KB |
testcase_02 | AC | 29 ms
10,752 KB |
testcase_03 | AC | 28 ms
10,752 KB |
testcase_04 | AC | 39 ms
10,880 KB |
testcase_05 | AC | 42 ms
10,752 KB |
testcase_06 | AC | 459 ms
10,752 KB |
testcase_07 | AC | 564 ms
10,752 KB |
testcase_08 | AC | 347 ms
10,880 KB |
testcase_09 | AC | 335 ms
10,752 KB |
testcase_10 | AC | 347 ms
10,752 KB |
ソースコード
import sys def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [[c] * b for i in range(a)] def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print('Yes') def No(): print('No') def YES(): print('YES') def NO(): print('NO') sys.setrecursionlimit(10 ** 9) INF = 10 ** 19 MOD = 10 ** 9 + 7 EPS = 10 ** -10 N = INT() grid = [] for i in range(N): grid += list(input()) def check(grid): win = [0] * N for i in range(N): for j in range(i+1, N): if grid[i*N+j] == 'o': win[i] += 1 elif grid[i*N+j] == 'x': win[j] += 1 win = [(a, i) for i, a in enumerate(win)] win.sort(reverse=1) rank = [0] * N cur = 1 rank[win[0][1]] = cur for i in range(1, N): if win[i][0] != win[i-1][0]: cur += 1 rank[win[i][1]] = cur return rank[0] gtob = {} b = 0 for i in range(N): for j in range(i+1, N): gtob[i*N+j] = b b += 1 ans = INF for bit in range(1<<b): cur = grid[:] for i in range(N): for j in range(i+1, N): if cur[i*N+j] == '-': k = gtob[i*N+j] if bit>>k & 1: cur[i*N+j] = 'o' cur[j*N+i] = 'x' else: cur[i*N+j] = 'x' cur[j*N+i] = 'o' ans = min(ans, check(cur)) print(ans)