QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#153135#5607. Cribbage On SteroidsLamberlainMuliWA 15ms9240kbPython32.6kb2023-08-29 14:33:582023-08-29 14:34:00

Judging History

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

  • [2023-08-29 14:34:00]
  • 评测
  • 测评结果:WA
  • 用时:15ms
  • 内存:9240kb
  • [2023-08-29 14:33:58]
  • 提交

answer

n=int(input())
count=0
sets=[]
cards=[]
ranks=['A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K']
value={}
for rank in ranks:
    if rank == 'A':
        value[rank]=1
    elif rank in ['T','J','Q','K']:
        value[rank]=10
    else:
        value[rank]=int(rank)
        
while len(cards)!=n:
    new=[x for x in input().split()]
    cards=cards+new
    sets.append(new)
freq={}
freq_values={}
for card in cards:
    if card not in freq:
        freq[card]=1
    else:
        freq[card]+=1

for card in cards:
    if value[card] not in freq_values:
        if card == 'A':
            freq_values[1]=1
        elif card in ['T','J','Q','K']:
            freq_values[10]=1
        else:
            freq_values[int(card)]=1
    else:
        if card == 'A':
            freq_values[1]+=1
        elif card in ['T','J','Q','K']:
            freq_values[10]+=1
        else:
            freq_values[int(card)]+=1
            
for rank in ranks:
    if rank not in cards:
        freq[rank]=0
    if value[rank] not in freq_values:
        if rank=='A':
            freq_values[1]=0
        elif rank in ['T','J','Q','K']:
            freq_values[10]=0
        else:
            freq_values[int(rank)]=0
            
fifteens=[]
for i in range(2,16):
    def solve(j,i,sol,sm):
        global sols
        if j==i:
            if sm==15:
                fifteens.append(sol)
        elif sm>15:
            return
        else:
            mn=1 if len(sol)==0 else sol[-1]
            for k in range(mn,min(11,15-sm+1)):
                solve(j+1,i,sol+[k],sm+k)
    solve(0,i,[],0)
from math import *
points=0
for fifteen in fifteens:
    comb_freq={}
    for num in fifteen:
        if num not in comb_freq:
            comb_freq[num]=1
        else:
            comb_freq[num]+=1
    if all([freq_values[x]>=comb_freq[x] for x in comb_freq.keys()]):
        p=1
        for y in comb_freq.keys():
            p*=comb(freq_values[y],comb_freq[y])
        points+=2*p

for card,f in freq.items():
    if f>=2:
        points+=f*(f-1)

for set in sets:
    f={}
    for card in set:
        if card not in f:
            f[card]=1
        else:
            f[card]+=1
    for rank in ranks:
        if rank not in set:
            f[rank]=0
    start=0
    while start<=10:
        mx=1
        for run in range(3,13-start+1):
            if all([(f[ranks[start+i]]>0) for i in range(run)]):
                mx=run
        prod=1
        for i in range(mx):
            prod*=f[ranks[start+i]]
        points+=prod*mx
        start = start+mx        
print(points)

詳細信息

Test #1:

score: 100
Accepted
time: 9ms
memory: 9100kb

input:

5
4 5 6 5 5

output:

23

result:

ok single line: '23'

Test #2:

score: 0
Accepted
time: 15ms
memory: 9100kb

input:

13
A 2 3 4 5
6 7 8 9 T
J Q K

output:

71

result:

ok single line: '71'

Test #3:

score: 0
Accepted
time: 13ms
memory: 9116kb

input:

10
2 2 3 4 5 8 9 T J Q

output:

45

result:

ok single line: '45'

Test #4:

score: -100
Wrong Answer
time: 10ms
memory: 9240kb

input:

5
5 5 5 5 J

output:

33

result:

wrong answer 1st lines differ - expected: '28', found: '33'