QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#69877#5247. Walizki [C]tygrysek0 0ms0kbPython31.5kb2023-01-03 02:38:232023-01-03 02:38:24

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-03 02:38:24]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-01-03 02:38:23]
  • 提交

answer

import math
import numpy as np

n = int(input())

vk=[]
vvk=[]
vva=[]
vvb=[]
vkx=[]
vc=[]
va=[]
vb=[]
vac=[]
for i in range(n+1):
    vvk.append([])
    vva.append([])
    vvb.append([])
    va.append(int(0))
    vc.append(int(0))
    vb.append(int(0))
    vkx.append([0,0])
    vac.append(False)
vac[1]=True
va[1]=1
for i in range(n):
    linia = input()
    we = linia.split(" ")
    k=int(we[0])
    vkx[i+1][1]=k
    
    for j in range(k):
        b=int(we[j+1])
        vvk[i+1].append(b)
  
if vkx[1]==0:
    print("1")
else:
    vc[1]=vkx[1][1]
   
    vva[1].append(1)
    vvb[1].append(1)
    for i in range(n):
        if vac[i+1] and (vkx[i+1][1]>0):
            a=1
            k=1
            for j in range(len(vva[i+1])):
                a=math.gcd(int(k),int(vva[i+1][j]))
                k*=vva[i+1][j]
                k//=a
            va[i+1]=0
            for j in range(len(vva[i+1])):
                va[i+1]+=((k//vva[i+1][j])*vvb[i+1][j])
            vc[i+1]=va[i+1]*vkx[i+1][1]
            a=math.gcd(int(va[i+1]),int(vkx[i+1][1]))
            vc[i+1]//=a
            vc[i+1]//=va[i+1]
            vc[i+1]*=k

            c=((vc[i+1]//k)*va[i+1])//vkx[i+1][1]

            for j in range(len(vvk[i+1])):
                vva[vvk[i+1][j]].append(vc[i+1])
                vvb[vvk[i+1][j]].append(c)
                vac[vvk[i+1][j]]=True

    z=1
    for i in range(n):
        if vc[i+1]>1:
            a=math.gcd(int(z),int(vc[i+1]))
            z*=vc[i+1]//a
            
    print(int(z))

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

1
0

output:


result:


Subtask #2:

score: 0
Runtime Error

Test #12:

score: 0
Runtime Error

input:

2
1 2
0

output:


result:


Subtask #3:

score: 0
Runtime Error

Test #23:

score: 0
Runtime Error

input:

11
10 2 3 4 5 6 7 8 9 10 11
9 3 4 5 6 7 8 9 10 11
8 4 5 6 7 8 9 10 11
7 5 6 7 8 9 10 11
6 6 7 8 9 10 11
5 7 8 9 10 11
4 8 9 10 11
3 9 10 11
2 10 11
1 11
0

output:


result:


Subtask #4:

score: 0
Runtime Error

Test #34:

score: 0
Runtime Error

input:

12
11 2 3 4 5 6 7 8 9 10 11 12
10 3 4 5 6 7 8 9 10 11 12
9 4 5 6 7 8 9 10 11 12
8 5 6 7 8 9 10 11 12
7 6 7 8 9 10 11 12
6 7 8 9 10 11 12
5 8 9 10 11 12
4 9 10 11 12
3 10 11 12
2 11 12
1 12
0

output:


result:


Subtask #5:

score: 0
Runtime Error

Test #45:

score: 0
Runtime Error

input:

25
24 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
23 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
22 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
21 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
20 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ...

output:


result:


Subtask #6:

score: 0
Runtime Error

Test #56:

score: 0
Runtime Error

input:

26
25 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
24 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
23 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
22 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
21 6 7 8 9 10 11 12 13 14 15 ...

output:


result:


Subtask #7:

score: 0
Runtime Error

Test #67:

score: 0
Runtime Error

input:

61
60 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
59 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 ...

output:


result:


Subtask #8:

score: 0
Runtime Error

Test #78:

score: 0
Runtime Error

input:

62
61 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
60 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 ...

output:


result:


Subtask #9:

score: 0
Runtime Error

Test #89:

score: 0
Runtime Error

input:

91
90 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
89 3 4 5 6 7 8 9 10 11 12 13 14 ...

output:


result:


Subtask #10:

score: 0
Runtime Error

Test #101:

score: 0
Runtime Error

input:

92
91 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
90 3 4 5 6 7 8 9 10 11 12 13 ...

output:


result: