Submission #1397510


Source Code Expand

Copy
n=gets.to_i
a=gets.split.map(&:to_i)
dup=(1..n).find{|i|a.count(i)>1}
l,r=[a.index(dup),a.rindex(dup)]

t=v=(n+1).factorial
t2=v2=(l+n-r).factorial
v2*=(l+n-r+1)
u=1
u2=1
puts (1..n+1).map{|i|
  u*=i
  u2*=(i-1) if (i-1)>0
  v/=(n+2-i) if (n+2-i)>0
  v2/=(l+n-r-i+2) if (l+n-r-i+2)>0
  (t/u/v-t2/u*i/v2)%1000000007
}

Submission Info

Submission Time
Task D - 11
User mayumini
Language Ruby (2.3.3)
Score 0
Code Size 334 Byte
Status

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt
All 0 / 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
mx.txt
rnd_0.txt
rnd_1.txt
rnd_2.txt
rnd_3.txt
rnd_4.txt
sample1.txt
sample2.txt
sample3.txt