Submission #20541232


Source Code Expand

def main():
    import copy
    k = int(input())
    s = input()
    t = input()
    S = [0]*10
    T = [0]*10

    remain = [k]*10
    for i in range(4):
        remain[int(s[i])] -= 1
        remain[int(t[i])] -= 1
        S[int(s[i])] += 1
        T[int(t[i])] += 1
    remain_t = sum(remain) - k # ゼロ関係ないので
    # print(S,T,remain_t,remain)

    ans = 0
    for i in range(1,10):
        if remain[i] == 0:
            continue
        for j in range(1,10):
            if remain[j] == 0:
                continue
            if i==j:
                if remain[j] == 1:
                    continue
                t = remain[j]*(remain[j]-1)
            else:
                t = remain[i]*remain[j]
            # print(i,j,t)
            A = copy.deepcopy(S)
            A[i] += 1
            a_s = sum(i*10**(A[i]) for i in range(1,10))
            B = copy.deepcopy(T)
            B[j] += 1
            b_s = sum(i*10**(B[i]) for i in range(1,10))
            if a_s > b_s:
                ans += t
    ans /= remain_t*(remain_t-1)
    print(ans)





if __name__=="__main__":
    main()

Submission Info

Submission Time
Task D - Poker
User kenken0305
Language Python (3.8.2)
Score 400
Code Size 1157 Byte
Status AC
Exec Time 37 ms
Memory 9352 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 36
Set Name Test Cases
Sample 01_sample.txt, 02_sample.txt, 03_sample.txt, 04_sample.txt
All 01_sample.txt, 02_sample.txt, 03_sample.txt, 04_sample.txt, 05_hand.txt, 06_hand.txt, 07_random1.txt, 08_random1.txt, 09_random1.txt, 10_random1.txt, 11_random1.txt, 12_random1.txt, 13_random1.txt, 14_random2.txt, 15_random2.txt, 16_random2.txt, 17_random2.txt, 18_random2.txt, 19_random2.txt, 20_random2.txt, 21_random2.txt, 22_random2.txt, 23_random2.txt, 24_random3.txt, 25_random3.txt, 26_random3.txt, 27_random3.txt, 28_random3.txt, 29_random3.txt, 30_random3.txt, 31_random3.txt, 32_random3.txt, 33_random4.txt, 34_random4.txt, 35_random4.txt, 36_random4.txt
Case Name Status Exec Time Memory
01_sample.txt AC 33 ms 9148 KiB
02_sample.txt AC 23 ms 9232 KiB
03_sample.txt AC 27 ms 9044 KiB
04_sample.txt AC 28 ms 9172 KiB
05_hand.txt AC 30 ms 9232 KiB
06_hand.txt AC 24 ms 9232 KiB
07_random1.txt AC 24 ms 9348 KiB
08_random1.txt AC 31 ms 9056 KiB
09_random1.txt AC 25 ms 9056 KiB
10_random1.txt AC 31 ms 9352 KiB
11_random1.txt AC 27 ms 9168 KiB
12_random1.txt AC 22 ms 9280 KiB
13_random1.txt AC 24 ms 9020 KiB
14_random2.txt AC 25 ms 9056 KiB
15_random2.txt AC 23 ms 9216 KiB
16_random2.txt AC 31 ms 9220 KiB
17_random2.txt AC 28 ms 9280 KiB
18_random2.txt AC 28 ms 9056 KiB
19_random2.txt AC 27 ms 9056 KiB
20_random2.txt AC 22 ms 9172 KiB
21_random2.txt AC 37 ms 9212 KiB
22_random2.txt AC 25 ms 9056 KiB
23_random2.txt AC 29 ms 9240 KiB
24_random3.txt AC 26 ms 9280 KiB
25_random3.txt AC 25 ms 9348 KiB
26_random3.txt AC 31 ms 9348 KiB
27_random3.txt AC 31 ms 9228 KiB
28_random3.txt AC 22 ms 9056 KiB
29_random3.txt AC 30 ms 9284 KiB
30_random3.txt AC 32 ms 9348 KiB
31_random3.txt AC 34 ms 9064 KiB
32_random3.txt AC 24 ms 9056 KiB
33_random4.txt AC 29 ms 9348 KiB
34_random4.txt AC 23 ms 9056 KiB
35_random4.txt AC 19 ms 9052 KiB
36_random4.txt AC 21 ms 9060 KiB