QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#480137#4687. Weather ReportGeothermalCompile Error//C++201.3kb2024-07-16 08:41:402024-07-16 08:41:40

Judging History

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

  • [2024-07-16 08:41:40]
  • 评测
  • [2024-07-16 08:41:40]
  • 提交

answer

import heapq
N = int(input())
S = input()
A = [int(round(float(s)*1000000)+0.5) for s in S.split(' ')]



choose = []
for i in range(21):
    choose.append([])
    for j in range(21):
        if (i < j): 
            choose[i].append(0)
        elif (j == 0):
            choose[i].append(1)
        else:
            choose[i].append(choose[i-1][j-1] + choose[i-1][j])


ans = 0
q = []
for a in range(N+1):
    for b in range(N+1):
        for c in range(N+1):
            if (a+b+c <= N):
                cur = [a, b, c, N-a-b-c]
                ways = 1
                for i in range(4):
                    for j in range(cur[i]):
                        ways *= A[i]
                for i in range(N):
                    ways = ways / 1000000
                val = choose[N][a] * choose[N-a][b] * choose[N-a-b][c]
                heapq.heappush(q, [ways, val])

while len(q) > 1 or q[0][1] > 1:
    cur = heapq.heappop(q)
    if cur[1] == 1:
        nxt = heapq.heappop(q)
        heapq.heappush(q, [cur[0]+nxt[0], 1])
        ans += cur[0]+nxt[0]
        if (nxt[1] > 1):
            heapq.heappush(q, [nxt[0], nxt[1]-1])
    else:
       cnt = cur[1] // 2
       ans += cnt * 2 * cur[0]
       heapq.heappush(q, [cur[0]*2, cnt])
       if (cur[1] % 2 == 1):
           heapq.heappush(q, [cur[0], 1])

print(ans)






Details

answer.code:1:1: error: ‘import’ does not name a type
    1 | import heapq
      | ^~~~~~
answer.code:1:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’, which is not yet enabled with ‘-std=c++20’