Contest Duration: ~ (local time) (100 minutes) Back to Home

Submission #8103568

Source Code Expand

Copy
```import collections
mod = 10**9+7
fac = [1]
caf = [1]
n=int(input())

def pow(n,p):
res=1
while p >0:
if p%2==0:
n = n**2 % mod
p //= 2
else:
res = res * n % mod
p -= 1
return res % mod

for i in range(1,n+2):
fac.append((fac[i-1]*i)%mod)
caf.append(pow(fac[i],mod-2)%mod)

def ncr(n,r):
if n < r: return 0
return fac[n]*caf[r]*caf[n-r]

def main():
global n
a=list(map(int,input().split()))

ca= collections.Counter(a)
tyo= ca.most_common()[0][0]
kaburi=[i for i, x in enumerate(a) if x == tyo]

for i in range(1,n+2):
print((ncr(n+1,i)-ncr(n+1-(kaburi[1]-kaburi[0]+1),i-1))%mod)

main()
```

#### Submission Info

Submission Time 2019-10-24 13:11:30+0900 D - 11 hatamura5121 PyPy3 (2.4.0) 600 749 Byte AC 496 ms 81624 KB

#### Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt
All 600 / 600 1.txt, mx.txt, rnd_0.txt, rnd_1.txt, rnd_2.txt, rnd_3.txt, rnd_4.txt, sample1.txt, sample2.txt, sample3.txt
Case Name Status Exec Time Memory
1.txt 496 ms 81624 KB
mx.txt 442 ms 78936 KB
rnd_0.txt 425 ms 72072 KB
rnd_1.txt 398 ms 67860 KB
rnd_2.txt 292 ms 51548 KB
rnd_3.txt 276 ms 49244 KB
rnd_4.txt 315 ms 56156 KB
sample1.txt 165 ms 38256 KB
sample2.txt 164 ms 38256 KB
sample3.txt 168 ms 38512 KB