問題一覧 > 通常問題

No.43 Baseball Games

レベル : / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 253
作問者 : nmnmnmnmnmnmnm
お気に入りにしたユーザー ProblemId : 8 / 自分の提出
問題文最終更新日: 2026-06-25 10:44:40
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 40 (順位表) の他の問題:

Problem Statement

There are N baseball teams.
K belongs to team number 0.

All teams will play a round-robin tournament.
In the round-robin, all teams play 1 game against each other.
Every game has a definite winner and loser, and there are no draws.

Ranks are determined starting from 1st place, in descending order of the number of wins.
Teams with the same number of wins share the same rank, so multiple teams may have the same rank.
Also, ranks are determined starting from 1st place, and no number is skipped.

For example, even if 2 teams are in 1st place, the next rank is 2nd place.
The next rank does not become 3rd place just because 2 teams are in 1st place.
You are given the current table of wins and losses.
If there are remaining games, consider the patterns of wins and losses for those remaining games.
Answer the best rank that K's team, team 0, can possibly achieve.

Input

N
\(s_{0,0}\,s_{0,1}\,\dots s_{0,n-1}\)
\(s_{1,0}\,s_{1,1}\,\dots s_{1,n-1}\)
\(          \dots                  \)
\(s_{n-1,0}\,s_{n-1,1}\,\dots\,s_{n-1,n-1}\)

$ 2 \le N \le 6$ ($N$ is an integer)
si,j represents the result of the game of team i against team j.
'o' means a win, 'x' means a loss, and '-' means the game has not been played yet.
A match of a team against itself is represented by '#'.
The results of K's team, team 0, are in the first row of the table.
The table contains no impossible results, such as both teams winning.

Output

Ans

Output Ans, the best rank of team 0.
Do not forget to print a newline after the answer.

Sample

Sample 1
Input
2
#-
-#
Output
1

Row 0 of the table holds the results of team 0.
Team 0 and team 1 have not played their game yet.
If team 0 wins the game, it takes 1st place, so the best rank team 0 can achieve is 1st place.

Sample 2
Input
2
#x
o#
Output
2

All games have already finished in the current state.
Team 0 has 0 wins and team 1 has 1 win.
There are no more remaining games.
Therefore, the best rank of team 0 is fixed at 2nd place.

Sample 3
Input
3
#xx
o#-
o-#
Output
3

Team 0 is already certain to have 2 losses.
The result between team 1 and team 2 is not decided yet.
Whichever of team 1 and team 2 wins, the best rank of team 0 is 3rd place.

Sample 4
Input
4
#-xx
-#x-
oo#-
o--#
Output
2

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