Submission #2228101


Source Code Expand

from collections import Counter
mod = 10**9 + 7
n = int(input())
A = [int(i) for i in input().split()]
C = Counter(A)
l = 0
for i in range(1,n+1):
	if C[i] > 1:
		l = i
		p = []
		for j in range(n+1):
			if A[j] == l:
				p.append(j)
				if len(p) > 1:
					break
		break
	if l:
		break

t = 1
d = 1
for k in range(n+1):

	t *= (n+1-k)%mod
	t %= mod
	t *= pow(k+1,mod-2,mod)
	t %= mod
	if not k:
		print(n)
	elif k <= n+p[0]-p[1]:
		d *= (n+p[0]-p[1]-k+1)%mod
		d %= mod
		d *= pow(k,mod-2,mod)
		d %= mod
		print((t - d)%mod)
	else:
		print(t%mod)

Submission Info

Submission Time
Task D - 11
User TAB
Language Python (3.4.3)
Score 600
Code Size 588 Byte
Status AC
Exec Time 1008 ms
Memory 19936 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 10
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All 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 AC 1008 ms 19424 KB
mx.txt AC 615 ms 19936 KB
rnd_0.txt AC 741 ms 13920 KB
rnd_1.txt AC 526 ms 12800 KB
rnd_2.txt AC 211 ms 6548 KB
rnd_3.txt AC 185 ms 6060 KB
rnd_4.txt AC 219 ms 8472 KB
sample1.txt AC 20 ms 3316 KB
sample2.txt AC 20 ms 3316 KB
sample3.txt AC 20 ms 3316 KB