問題一覧 > 通常問題

No.1937 Various Tournament

レベル : / AI推定難易度 : 1700 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 55
作問者 : noya2 / テスター : tatyam chineristAC
お気に入りにしたユーザー ProblemId : 7563 / 自分の提出
問題文最終更新日: 2022-05-14 11:03:53
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 343 (順位表) の他の問題:

Problem Statement

You are given a positive integer $N$. Here, $N$ is one of $2,4,8,16$.

A boxing tournament will be held with $N$ participants numbered $1,2,\dots ,N$. The tournament proceeds as follows.

  • Arrange the $N$ participants in a row in some order.
  • Each participant at an odd position from the left has exactly $1$ boxing match against the participant immediately to their right; the winner stays in the row and the loser is eliminated from the row. This is repeated until $1$ person remains in the row.
  • The $1$ person who remains last is the champion, and the tournament ends.

Noya investigated how each participant matches up against each other participant and created a table $S$ with $N$ rows and $N$ columns. This table represents the following.

    For any $i,j\ (1\le i\lt j\le N)$, if $S_{i,\ j}=1$ then participant $i$ always beats participant $j$, and if $S_{i,\ j}=0$ then participant $i$ always loses to participant $j$.

Here, for $1\le i,\ j\le N$, it is guaranteed that $S_{i,\ j} + S_{j,\ i}=1$ if $i\neq j$, and $S_{i,\ j}=0$ if $i=j$.


There are $N!$ ways to arrange the $N$ participants in a row. Among them, how many ways result in participant $k$ becoming the champion?

Output the answer for each of $k=1,2,\dots ,N$.

Constraints

  • All inputs are integers.
  • $N$ is one of $2,4,8,16$
  • $S_{i,j}$ is one of $0,1$
  • $S_{i,j} + S_{j,i} = 1\ (i\neq j)$
  • $S_{i,i}=0$
  • Input

    $N$
    $S_{1,1}$ $S_{1,2}$ $\dots$ $S_{1,N}$
    $\vdots$
    $S_{N,1}$ $S_{N,2}$ $\dots$ $S_{N,N}$
    

    Output

    Output $N$ lines. On the $i$-th line, output the answer for $k=i$.

    Sample

    Sample 1
    Input
    2
    0 1
    0 0
    Output
    2
    0

    Participant $1$ always beats participant $2$. There are $2$ ways to arrange the participants, $(1,2),(2,1)$, and participant $1$ becomes the champion in both.

    Sample 2
    Input
    4
    0 1 0 1
    0 0 1 0
    1 0 0 1
    0 1 0 0
    Output
    8
    0
    16
    0

    Unfortunately, participants $2,4$ have no chance of winning.

    Sample 3
    Input
    8
    0 1 0 1 0 1 0 1
    0 0 1 0 1 0 1 0
    1 0 0 1 0 1 0 1
    0 1 0 0 1 0 1 0
    1 0 1 0 0 1 0 1
    0 1 0 1 0 0 1 0
    1 0 1 0 1 0 0 1
    0 1 0 1 0 1 0 0
    Output
    4480
    4352
    5888
    2944
    8320
    1664
    11648
    1024

    Who becomes the champion depends on how the participants are arranged.

    提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。