QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#575459#9308. World CupyylxWA 14ms10616kbPython31.7kb2024-09-19 14:29:132024-09-19 14:29:13

Judging History

你现在查看的是最新测评结果

  • [2024-09-19 14:29:13]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:10616kb
  • [2024-09-19 14:29:13]
  • 提交

answer

def best_possible_result(strengths):
  """
  Calculates the best possible result for the Chinese team in the World Cup,
  considering the ability to manipulate the grouping scheme.

  Args:
      strengths: A list of integers representing the strengths of all 32 teams.

  Returns:
      An integer representing the best possible result for the Chinese team:
      1: Champion, 2: Runner-up, 4: Semi-finalist, 8: Quarter-finalist,
      16: Round of 16, 32: Did not advance.
  """

  chinese_team_strength = strengths[0]

  # Sort strengths in descending order
  strengths.sort(reverse=True)

  # Find the rank of the Chinese team
  chinese_team_rank = strengths.index(chinese_team_strength) + 1

  # If the Chinese team is not in the top 16, they can't advance to the knockout stage
  if chinese_team_rank > 16:
    return 32

  # In the group stage, we can ensure the Chinese team is in a group
  # where they are at least the 2nd strongest, guaranteeing advancement
  
  # In the knockout stage (round of 16), they will face a group winner,
  # which could be any of the top 8 teams

  # Best possible scenario: Chinese team wins against all but the strongest team
  if chinese_team_rank == 2:
    return 2  # Runner-up

  # Next best scenarios: Chinese team loses in the semi-final or quarter-final
  if chinese_team_rank <= 4:
    return 4  # Semi-finalist
  if chinese_team_rank <= 8:
    return 8  # Quarter-finalist

  # Otherwise, they are guaranteed to reach at least the round of 16
  return 16

# Read the number of test cases
t = int(input())

for _ in range(t):
  strengths = list(map(int, input().split()))
  result = best_possible_result(strengths)
  print(result)

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 14ms
memory: 10616kb

input:

1
32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1

output:

4

result:

wrong answer 1st numbers differ - expected: '1', found: '4'