結果

問題 No.1937 Various Tournament
ユーザー qwewe
提出日時 2025-05-14 12:55:37
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 774 bytes
コンパイル時間 243 ms
コンパイル使用メモリ 82,300 KB
実行使用メモリ 84,016 KB
最終ジャッジ日時 2025-05-14 12:56:32
合計ジャッジ時間 3,877 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 1 TLE * 1 -- * 45
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import permutations

def main():
    N = int(sys.stdin.readline())
    S = []
    for _ in range(N):
        S.append(list(map(int, sys.stdin.readline().split())))
    ans = [0] * (N + 1)
    for perm in permutations(range(1, N + 1)):
        current = list(perm)
        while len(current) > 1:
            next_round = []
            for i in range(0, len(current), 2):
                a = current[i]
                b = current[i+1]
                if S[a-1][b-1]:
                    next_round.append(a)
                else:
                    next_round.append(b)
            current = next_round
        winner = current[0]
        ans[winner] += 1
    for i in range(1, N + 1):
        print(ans[i])

if __name__ == "__main__":
    main()
0