Submission #172174


Source Code Expand

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

NUM_MOD =1000000007

N = int(sys.stdin.readline().rstrip())
As = map(int, sys.stdin.readline().rstrip().split())

def get_sigma(start, end, num):
    n_range = end-start+1
    memo = [1 for i in xrange(n_range)]

    for i in xrange(num-1):
        memo = [sum(memo[:i+1])%NUM_MOD for i in xrange(n_range)]
        continue
        nexmemo = [memo[0]]
        for item in memo[1:]:
            nexmemo.append((nexmemo[-1] + item)%NUM_MOD)
        memo = nexmemo
        #print memo
    return sum(memo)
    

#print gamemap
#print ([(y, lim-y) for lim in xrange(D%2, D+1, 2) for y in xrange(lim+1)])
# print ([gamemap[y][lim-y]
#            for lim in xrange(D%2, D+1, 2) 
#            for y in xrange(lim+1)])

# print max([gamemap[y][lim-y]
#            for lim in xrange(D%2, D+1, 2) 
#            for y in xrange(lim+1)
#            if y < len(gamemap) and lim-y < len(gamemap[y])])

#print get_sigma(1, 3, 1)
#print get_sigma(1, 3, 2)
#print get_sigma(1, 3, 3)

last, now = 0, 0
is_counting = False
count = 0
ans = 1
for A in As:
    if A == -1:
        is_counting = True
        count += 1
    else:
        now, last = A, now
        if is_counting:
            #print last, now, count
            ans *= get_sigma(last, now, count)
            ans = ans % NUM_MOD
            count = 0
            is_counting = False
print ans
exit(0)

Submission Info

Submission Time
Task C - タコヤ木
User hiking
Language Python (2.7.3)
Score 50
Code Size 1471 Byte
Status TLE
Exec Time 2063 ms
Memory 312780 KB

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3
Score / Max Score 0 / 0 50 / 50 0 / 30 0 / 20
Status
AC × 2
TLE × 1
AC × 14
AC × 25
TLE × 1
AC × 26
TLE × 10
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 49 ms 3328 KB
sample_02.txt AC 52 ms 3376 KB
sample_03.txt TLE 2059 ms 312780 KB
subtask1_01.txt AC 48 ms 3380 KB
subtask1_02.txt AC 52 ms 3316 KB
subtask1_03.txt AC 52 ms 3388 KB
subtask1_04.txt AC 49 ms 3380 KB
subtask1_05.txt AC 48 ms 3380 KB
subtask1_06.txt AC 49 ms 3376 KB
subtask1_07.txt AC 61 ms 3388 KB
subtask1_08.txt AC 49 ms 3372 KB
subtask1_09.txt AC 48 ms 3324 KB
subtask1_10.txt AC 49 ms 3384 KB
subtask1_11.txt AC 49 ms 3380 KB
subtask1_12.txt AC 49 ms 3380 KB
subtask2_01.txt AC 48 ms 3392 KB
subtask2_02.txt AC 49 ms 3384 KB
subtask2_03.txt AC 58 ms 3476 KB
subtask2_04.txt AC 50 ms 3500 KB
subtask2_05.txt AC 50 ms 3496 KB
subtask2_06.txt AC 51 ms 3500 KB
subtask2_07.txt TLE 2030 ms 3636 KB
subtask2_08.txt AC 50 ms 3500 KB
subtask2_09.txt AC 51 ms 3332 KB
subtask2_10.txt AC 71 ms 3492 KB
subtask2_11.txt AC 52 ms 3504 KB
subtask2_12.txt AC 51 ms 3508 KB
subtask3_01.txt AC 49 ms 3384 KB
subtask3_02.txt TLE 2061 ms 310864 KB
subtask3_03.txt TLE 2041 ms 94788 KB
subtask3_04.txt TLE 2030 ms 5500 KB
subtask3_05.txt TLE 2035 ms 49416 KB
subtask3_06.txt TLE 2030 ms 6252 KB
subtask3_07.txt TLE 2063 ms 308580 KB
subtask3_08.txt AC 51 ms 3452 KB
subtask3_09.txt AC 53 ms 3504 KB
subtask3_10.txt TLE 2032 ms 19344 KB
subtask3_11.txt TLE 2036 ms 61412 KB
subtask3_12.txt TLE 2030 ms 8460 KB