hiho week 113 register

Ended

Participants:356

Verdict:Accepted
Score:100 / 100
Submitted:2016-09-01 21:44:02

Lang:Python2

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
a1 = [0,0]
a2 = [1,1]
n = int(raw_input())
s = [int(i) for i in raw_input().split()]
if n==0:
    print 0
    exit()
for i in s:
    if i == 1:
        if a1[0] > 0:
            a1[1] = (a1[1]+a1[0])%1000000007
            a1[0] = (a1[0]+1)%1000000007
            if len(a2) == 2:
                a1.append(0)
                a2.append(2)
        else:
            a1[0] = (a1[0]+1)%1000000007
    elif i in a2:
        j = a2.index(i)
        a1[j] = (a1[j]+a1[j-1])%1000000007
        if j==len(a2)-1:
            a2.append(a2[j-1]+a2[j])
            a1.append(0)
num = 0
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX