QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#184901#5607. Cribbage On Steroidsucup-team004Compile Error//C++20845b2023-09-21 14:08:322023-09-21 14:08:32

Judging History

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

  • [2023-09-21 14:08:32]
  • 评测
  • [2023-09-21 14:08:32]
  • 提交

answer

def rank(c) :
    mp = {'A' : 1, 'T' : 10, 'J' : 11, 'Q' : 12, 'K' : 13}
    if c in mp :
        return mp[c]
    return ord(c) - ord('0')

cnt = [0] * 14
n = int(input())
tot = 0
while tot < n :
    s = input().split()
    for c in s :
        cnt[rank(c)] += 1
        tot += 1
dp = [0] * 16
dp[0] = 1
for c in range(1, 14) :
    v = min(c, 10)
    for t in range(cnt[c]) :
        for j in range(15, v - 1, -1) :
            dp[j] += dp[j - v]
ans = dp[15] * 2
for c in range(1, 14) :
    ans += cnt[c] * (cnt[c] - 1)
l = 1
r = 1
while l < 14 :
    if cnt[l] == 0 :
        l += 1
        continue
    r = l
    while r < 14 and cnt[r] > 0 :
        r += 1
    if r - l >= 3 :
        prod = 1
        for j in range(l, r) :
            prod *= cnt[j]
        ans += prod * (r - l)
    l = r
print(ans)

Details

answer.code:1:1: error: ‘def’ does not name a type
    1 | def rank(c) :
      | ^~~
answer.code:3:5: error: expected unqualified-id before ‘if’
    3 |     if c in mp :
      |     ^~