結果
問題 |
No.1937 Various Tournament
|
ユーザー |
|
提出日時 | 2022-05-13 23:11:47 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 749 bytes |
コンパイル時間 | 269 ms |
コンパイル使用メモリ | 82,488 KB |
実行使用メモリ | 463,072 KB |
最終ジャッジ日時 | 2024-07-22 03:30:14 |
合計ジャッジ時間 | 3,768 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 1 TLE * 1 -- * 45 |
ソースコード
import sys from itertools import permutations sys.setrecursionlimit(10 ** 7) def get_list(ty=int): return list(map(ty, input().split())) def get_int(): return int(input()) def get_str(): return input() N = get_int() S = [] for n in range(N): S.append(get_list()) cache = {} def rec(p): if p in cache: return cache[p] if len(p) == 2: cache[p] = p[0] if S[p[0]][p[1]] else p[1] return cache[p] idx = [] for i in range(0, 1 + len(p) // 2, len(p) // 2): idx.append(rec(p[i:(i + len(p) // 2)])) cache[p] = idx[0] if S[idx[0]][idx[1]] else idx[1] return cache[p] cnt = [0] * N for p in permutations(range(N)): cnt[rec(p)] += 1 for n in range(N): print(cnt[n])