結果
問題 |
No.1937 Various Tournament
|
ユーザー |
![]() |
提出日時 | 2022-05-18 03:30:32 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,311 bytes |
コンパイル時間 | 252 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 86,184 KB |
最終ジャッジ日時 | 2024-09-16 02:42:35 |
合計ジャッジ時間 | 3,957 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 1 TLE * 1 -- * 45 |
ソースコード
from collections import Counter N=int(input()) S=[list(map(int,input().split())) for i in range(N)] ANS=[0]*N def listbit(x): for i in range(1<<x): count=0 for j in range(x): if i & (1<<j) != 0: count+=1 if count==x//2: yield i LBIT=[-1]*20 LBIT[2]=list(listbit(2)) LBIT[4]=list(listbit(4)) LBIT[8]=list(listbit(8)) LBIT[16]=list(listbit(16)) def win(x,y): if S[x][y]==1: return x else: return y def calc(X,f): if len(X)==2: a,b=X[0],X[1] DX=Counter() if S[a][b]==1: DX[a]=f else: DX[b]=f return DX DD=Counter() for i in LBIT[len(X)]: Y=[] Z=[] for j in range(len(X)): if i & (1<<j) == 0: Y.append(X[j]) else: Z.append(X[j]) #print("!",Y,Z) if len(Y)==len(X)//2: #print(Y,Z) D1=calc(Y,f) D2=calc(Z,f) for d1 in D1: for d2 in D2: DD[win(d1,d2)]+=D1[d1]*D2[d2] return DD D=calc(list(range(N)),1) if N==2: k=2 elif N==4: k=4 elif N==8: k=16 else: k=16*16 for i in range(N): print(D[i]*k)