QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#647232#9370. Gambling on Choosing RegionalsleatriseCompile Error//C++141.4kb2024-10-17 12:53:412024-10-17 12:53:43

Judging History

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

  • [2024-10-17 12:53:43]
  • 评测
  • [2024-10-17 12:53:41]
  • 提交

answer

#temp

from collections import defaultdict

# 读取输入
n, k = map(int, input().split())
c = list(map(int, input().split()))

# 存储队伍信息 (综合实力, 大学缩写)
teams = []
for i in range(n):
    w, s = input().split()
    w = int(w)
    teams.append((w, s, i))  # 记录队伍实力,大学缩写,和原始索引

# 按综合实力从高到低排序
teams.sort(reverse=True, key=lambda x: x[0])

# 每所大学只能派出有限队伍,我们用字典来存储各个大学在每个区域赛的限制情况
university_limits = defaultdict(lambda: [0] * k)

# 结果列表
result = [0] * n

# 对于每支队伍,从实力最强到最弱开始分配区域赛
for w, university, original_index in teams:
    min_rank = 0
    total_capacity = 0
    
    # 计算所有比赛可以选择的总容量
    for i in range(k):
        available_slots = c[i] - university_limits[university][i]
        total_capacity += available_slots
        min_rank += available_slots

    # 记录该队伍的最小可能排名
    result[original_index] = n - total_capacity + 1

    # 分配队伍到比赛中(最坏情况下假设这个队伍加入最大的比赛容量中)
    for i in range(k):
        if university_limits[university][i] < c[i]:
            university_limits[university][i] += 1
            break

# 输出结果
for rank in result:
    print(rank)

詳細信息

answer.code:1:2: error: invalid preprocessing directive #temp
    1 | #temp
      |  ^~~~
answer.code:5:3: error: invalid preprocessing directive #\U00008bfb\U000053d6\U00008f93\U00005165
    5 | # 读取输入
      |   ^~~~~~~~
answer.code:9:3: error: invalid preprocessing directive #\U00005b58\U000050a8\U0000961f\U00004f0d\U00004fe1\U0000606f
    9 | # 存储队伍信息 (综合实力, 大学缩写)
      |   ^~~~~~~~~~~~
answer.code:14:30: error: stray ‘#’ in program
   14 |     teams.append((w, s, i))  # 记录队伍实力,大学缩写,和原始索引
      |                              ^
answer.code:16:3: error: invalid preprocessing directive #\U00006309\U00007efc\U00005408\U00005b9e\U0000529b\U00004ece\U00009ad8\U00005230\U00004f4e\U00006392\U00005e8f
   16 | # 按综合实力从高到低排序
      |   ^~~~~~~~~~~~~~~~~~~~~~
answer.code:19:3: error: invalid preprocessing directive #\U00006bcf\U00006240\U00005927\U00005b66\U000053ea\U000080fd\U00006d3e\U000051fa\U00006709\U00009650\U0000961f\U00004f0d\U0000ff0c\U00006211\U00004eec\U00007528\U00005b57\U00005178\U00006765\U00005b58\U000050a8\U00005404\U00004e2a\U00005927\U00005b66\U00005728\U00006bcf\U00004e2a\U0000533a\U000057df\U00008d5b\U00007684\U00009650\U00005236\U000060c5\U000051b5
   19 | # 每所大学只能派出有限队伍,我们用字典来存储各个大学在每个区域赛的限制情况
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:22:3: error: invalid preprocessing directive #\U00007ed3\U0000679c\U00005217\U00008868
   22 | # 结果列表
      |   ^~~~~~~~
answer.code:25:3: error: invalid preprocessing directive #\U00005bf9\U00004e8e\U00006bcf\U0000652f\U0000961f\U00004f0d\U0000ff0c\U00004ece\U00005b9e\U0000529b\U00006700\U00005f3a\U00005230\U00006700\U00005f31\U00005f00\U000059cb\U00005206\U0000914d\U0000533a\U000057df\U00008d5b
   25 | # 对于每支队伍,从实力最强到最弱开始分配区域赛
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:30:7: error: invalid preprocessing directive #\U00008ba1\U00007b97\U00006240\U00006709\U00006bd4\U00008d5b\U000053ef\U00004ee5\U00009009\U000062e9\U00007684\U0000603b\U00005bb9\U000091cf
   30 |     # 计算所有比赛可以选择的总容量
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:36:7: error: invalid preprocessing directive #\U00008bb0\U00005f55\U00008be5\U0000961f\U00004f0d\U00007684\U00006700\U00005c0f\U000053ef\U000080fd\U00006392\U0000540d
   36 |     # 记录该队伍的最小可能排名
      |       ^~~~~~~~~~~~~~~~~~~~~~~~
answer.code:39:7: error: invalid preprocessing directive #\U00005206\U0000914d\U0000961f\U00004f0d\U00005230\U00006bd4\U00008d5b\U00004e2d\U0000ff08\U00006700\U0000574f\U000060c5\U000051b5\U00004e0b\U00005047\U00008bbe\U00008fd9\U00004e2a\U0000961f\U00004f0d\U000052a0\U00005165\U00006700\U00005927\U00007684\U00006bd4\U00008d5b\U00005bb9\U000091cf\U00004e2d\U0000ff09
   39 |     # 分配队伍到比赛中(最坏情况下假设这个队伍加入最大的比赛容量中)
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:45:3: error: invalid preprocessing directive #\U00008f93\U000051fa\U00007ed3\U0000679c
   45 | # 输出结果
      |   ^~~~~~~~
answer.code:3:1: error: ‘from’ does not name a type
    3 | from collections import defaultdict
      | ^~~~