Submission #171815


Source Code Expand

Copy
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys

def main():
    n = int(sys.stdin.readline().rstrip())
    a = map(int,sys.stdin.readline().rstrip().split(" "))

    c = 1
    idx = -1
    for i,x in enumerate(a):
        if x==-1 and idx==-1:
            idx = i
        elif x!=-1 and idx!=-1:
            r = x-a[idx-1]+1
            j = i-idx

            p=q=1
            r+=j-1
            for k in xrange(1,j+1):
                p*=r
                r-=1
                q*=k
            c*=p/q
            c%=1000000007
            
            idx=-1
    print c
            

if __name__=='__main__':
    main()

Submission Info

Submission Time
Task C - タコヤ木
User qrrakakh
Language Python (2.7.3)
Score 100
Code Size 665 Byte
Status AC
Exec Time 63 ms
Memory 3508 KB

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3
Score / Max Score 0 / 0 50 / 50 30 / 30 20 / 20
Status
AC × 3
AC × 14
AC × 26
AC × 36
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt
Subtask2 sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt
Subtask3 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask3_01.txt, subtask3_02.txt, subtask3_03.txt, subtask3_04.txt, subtask3_05.txt, subtask3_06.txt, subtask3_07.txt, subtask3_08.txt, subtask3_09.txt, subtask3_10.txt, subtask3_11.txt, subtask3_12.txt
Case Name Status Exec Time Memory
sample_01.txt AC 59 ms 3388 KB
sample_02.txt AC 49 ms 3384 KB
sample_03.txt AC 48 ms 3380 KB
subtask1_01.txt AC 50 ms 3388 KB
subtask1_02.txt AC 47 ms 3380 KB
subtask1_03.txt AC 48 ms 3384 KB
subtask1_04.txt AC 49 ms 3392 KB
subtask1_05.txt AC 48 ms 3384 KB
subtask1_06.txt AC 49 ms 3380 KB
subtask1_07.txt AC 51 ms 3380 KB
subtask1_08.txt AC 48 ms 3324 KB
subtask1_09.txt AC 47 ms 3324 KB
subtask1_10.txt AC 46 ms 3388 KB
subtask1_11.txt AC 48 ms 3388 KB
subtask1_12.txt AC 49 ms 3376 KB
subtask2_01.txt AC 50 ms 3328 KB
subtask2_02.txt AC 49 ms 3316 KB
subtask2_03.txt AC 52 ms 3388 KB
subtask2_04.txt AC 51 ms 3384 KB
subtask2_05.txt AC 51 ms 3388 KB
subtask2_06.txt AC 52 ms 3376 KB
subtask2_07.txt AC 55 ms 3508 KB
subtask2_08.txt AC 52 ms 3504 KB
subtask2_09.txt AC 53 ms 3328 KB
subtask2_10.txt AC 48 ms 3328 KB
subtask2_11.txt AC 48 ms 3504 KB
subtask2_12.txt AC 63 ms 3488 KB
subtask3_01.txt AC 53 ms 3384 KB
subtask3_02.txt AC 53 ms 3324 KB
subtask3_03.txt AC 47 ms 3328 KB
subtask3_04.txt AC 54 ms 3496 KB
subtask3_05.txt AC 50 ms 3304 KB
subtask3_06.txt AC 51 ms 3496 KB
subtask3_07.txt AC 61 ms 3324 KB
subtask3_08.txt AC 52 ms 3492 KB
subtask3_09.txt AC 53 ms 3504 KB
subtask3_10.txt AC 50 ms 3496 KB
subtask3_11.txt AC 51 ms 3504 KB
subtask3_12.txt AC 52 ms 3428 KB