Task: | jedan |
Sender: | Kuha |
Submission time: | 2016-08-02 16:24:19 +0300 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.06 s | details |
#2 | ACCEPTED | 0.06 s | details |
#3 | ACCEPTED | 0.05 s | details |
#4 | ACCEPTED | 0.05 s | details |
#5 | ACCEPTED | 0.07 s | details |
#6 | ACCEPTED | 0.06 s | details |
#7 | ACCEPTED | 0.06 s | details |
#8 | ACCEPTED | 0.06 s | details |
#9 | ACCEPTED | 0.06 s | details |
#10 | ACCEPTED | 0.06 s | details |
#11 | ACCEPTED | 0.05 s | details |
#12 | ACCEPTED | 0.06 s | details |
#13 | ACCEPTED | 0.06 s | details |
#14 | ACCEPTED | 0.05 s | details |
#15 | ACCEPTED | 0.07 s | details |
#16 | ACCEPTED | 0.06 s | details |
#17 | ACCEPTED | 0.05 s | details |
#18 | ACCEPTED | 0.06 s | details |
#19 | ACCEPTED | 0.07 s | details |
#20 | ACCEPTED | 0.06 s | details |
#21 | ACCEPTED | 0.06 s | details |
#22 | ACCEPTED | 0.05 s | details |
#23 | ACCEPTED | 0.06 s | details |
#24 | ACCEPTED | 0.05 s | details |
#25 | ACCEPTED | 0.06 s | details |
#26 | ACCEPTED | 0.06 s | details |
#27 | ACCEPTED | 0.09 s | details |
#28 | ACCEPTED | 0.15 s | details |
#29 | ACCEPTED | 0.17 s | details |
#30 | ACCEPTED | 0.25 s | details |
#31 | ACCEPTED | 0.25 s | details |
#32 | ACCEPTED | 0.26 s | details |
#33 | ACCEPTED | 0.26 s | details |
#34 | ACCEPTED | 0.07 s | details |
#35 | ACCEPTED | 0.09 s | details |
#36 | ACCEPTED | 0.14 s | details |
#37 | ACCEPTED | 0.17 s | details |
#38 | ACCEPTED | 0.26 s | details |
Code
#include <bits/stdc++.h> #define ll long long #define INF 999999999 #define LINF 999999999999999999LL #define N (1<<20) #define M 1000000007 using namespace std; int mi[10001]; int ma[10001]; ll dp[10000][2]; int main () { int n; cin>>n; for (int i = 0; i < n; i++) { mi[i] = 0; ma[i] = n - n / 2 - min(abs(i - n / 2), abs(i - (n - 1) / 2)) - 1; } for (int i = 0; i < n; i++) { int x; cin>>x; if (n == 1 && x > 0) cout<<0<<endl, exit(0); if (x == -1) continue; mi[i] = x; ma[i] = x; } int c = 0; for (int i = 0; i < n; i++) { c = max(c - 1, mi[i]); mi[i] = max(c, mi[i]); } for (int i = n - 1; i >= 0; i--) { c = max(c - 1, mi[i]); mi[i] = max(c, mi[i]); } c = 0; for (int i = 0; i < n; i++) { c = min(c + 1, ma[i]); ma[i] = min(c, ma[i]); } for (int i = n - 1; i >= 0; i--) { c = min(c + 1, ma[i]); ma[i] = min(c, ma[i]); } for (int i = 0; i < n; i++) { if (mi[i] > ma[i]) cout<<0<<endl, exit(0); } dp[0][0] = 1; for (int x = 1; x < n; x++) { for (int y = mi[x]; y <= ma[x]; y++) { dp[y][1] += (dp[y + 1][0] + dp[y][0]) % M; if (y) dp[y][1] = (dp[y][1] + dp[y - 1][0]) % M; } for (int y = max(mi[x] - 1, 0); y <= ma[x] + 1; y++) { dp[y][0] = dp[y][1]; } for (int y = max(mi[x] - 2, 0); y <= ma[x] + 2; y++) dp[y][1] = 0; } cout<<dp[0][0]<<endl; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
3
-1 2 -1 |
correct output |
---|
0 |
user output |
---|
0 |
Test 2
Verdict: ACCEPTED
input |
---|
3
-1 -1 -1 |
correct output |
---|
2 |
user output |
---|
2 |
Test 3
Verdict: ACCEPTED
input |
---|
6
-1 -1 -1 2 -1 -1 |
correct output |
---|
3 |
user output |
---|
3 |
Test 4
Verdict: ACCEPTED
input |
---|
1
-1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 5
Verdict: ACCEPTED
input |
---|
1
0 |
correct output |
---|
1 |
user output |
---|
1 |
Test 6
Verdict: ACCEPTED
input |
---|
1
1 |
correct output |
---|
0 |
user output |
---|
0 |
Test 7
Verdict: ACCEPTED
input |
---|
15
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ... |
correct output |
---|
113634 |
user output |
---|
113634 |
Test 8
Verdict: ACCEPTED
input |
---|
30
-1 -1 -1 -1 -1 -1 -1 -1 7 -1 -... |
correct output |
---|
33792 |
user output |
---|
33792 |
Test 9
Verdict: ACCEPTED
input |
---|
40
-1 -1 -1 -1 -1 -1 -1 6 -1 -1 -... |
correct output |
---|
44058168 |
user output |
---|
44058168 |
Test 10
Verdict: ACCEPTED
input |
---|
50
-1 -1 -1 -1 4 -1 -1 -1 -1 -1 -... |
correct output |
---|
885261321 |
user output |
---|
885261321 |
Test 11
Verdict: ACCEPTED
input |
---|
100
-1 -1 -1 -1 -1 -1 -1 -1 7 -1 -... |
correct output |
---|
630105363 |
user output |
---|
630105363 |
Test 12
Verdict: ACCEPTED
input |
---|
200
0 -1 -1 -1 4 -1 -1 -1 -1 0 -1 ... |
correct output |
---|
584749136 |
user output |
---|
584749136 |
Test 13
Verdict: ACCEPTED
input |
---|
300
-1 -1 0 -1 -1 -1 -1 -1 -1 -1 -... |
correct output |
---|
440962689 |
user output |
---|
440962689 |
Test 14
Verdict: ACCEPTED
input |
---|
500
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ... |
correct output |
---|
861085225 |
user output |
---|
861085225 |
Test 15
Verdict: ACCEPTED
input |
---|
499
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ... |
correct output |
---|
686858355 |
user output |
---|
686858355 |
Test 16
Verdict: ACCEPTED
input |
---|
500
0 0 -1 -1 -1 3 -1 -1 -1 6 6 -1... |
correct output |
---|
287620623 |
user output |
---|
287620623 |
Test 17
Verdict: ACCEPTED
input |
---|
500
0 -1 -1 1 -1 0 -1 0 -1 -1 3 -1... |
correct output |
---|
132437565 |
user output |
---|
132437565 |
Test 18
Verdict: ACCEPTED
input |
---|
500
0 -1 1 -1 2 2 -1 4 -1 -1 -1 1 ... |
correct output |
---|
545015067 |
user output |
---|
545015067 |
Test 19
Verdict: ACCEPTED
input |
---|
500
-1 1 1 -1 1 -1 1 -1 -1 1 -1 -1... |
correct output |
---|
394701022 |
user output |
---|
394701022 |
Test 20
Verdict: ACCEPTED
input |
---|
500
0 -1 -1 2 -1 -1 -1 -1 -1 -1 -1... |
correct output |
---|
287409105 |
user output |
---|
287409105 |
Test 21
Verdict: ACCEPTED
input |
---|
500
0 -1 -1 -1 -1 -1 -1 -1 -1 -1 -... |
correct output |
---|
455719894 |
user output |
---|
455719894 |
Test 22
Verdict: ACCEPTED
input |
---|
500
-1 1 -1 -1 -1 -1 -1 -1 -1 -1 -... |
correct output |
---|
174226870 |
user output |
---|
174226870 |
Test 23
Verdict: ACCEPTED
input |
---|
500
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ... |
correct output |
---|
861085225 |
user output |
---|
861085225 |
Test 24
Verdict: ACCEPTED
input |
---|
1000
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ... |
correct output |
---|
812718674 |
user output |
---|
812718674 |
Test 25
Verdict: ACCEPTED
input |
---|
2000
-1 1 -1 -1 -1 -1 -1 -1 -1 -1 -... |
correct output |
---|
93994771 |
user output |
---|
93994771 |
Test 26
Verdict: ACCEPTED
input |
---|
3000
-1 0 -1 -1 -1 -1 -1 -1 -1 -1 -... |
correct output |
---|
335231082 |
user output |
---|
335231082 |
Test 27
Verdict: ACCEPTED
input |
---|
5000
0 -1 2 -1 1 2 -1 -1 5 -1 -1 7 ... |
correct output |
---|
799295101 |
user output |
---|
799295101 |
Test 28
Verdict: ACCEPTED
input |
---|
7000
0 -1 0 0 -1 0 -1 1 0 1 0 0 -1 ... |
correct output |
---|
436287141 |
user output |
---|
436287141 |
Test 29
Verdict: ACCEPTED
input |
---|
8000
0 -1 1 -1 3 -1 1 -1 1 0 -1 -1 ... |
correct output |
---|
88524447 |
user output |
---|
88524447 |
Test 30
Verdict: ACCEPTED
input |
---|
10000
0 0 1 -1 -1 3 2 -1 3 -1 4 -1 5... |
correct output |
---|
129950957 |
user output |
---|
129950957 |
Test 31
Verdict: ACCEPTED
input |
---|
10000
-1 0 -1 -1 3 2 -1 -1 -1 -1 1 -... |
correct output |
---|
598246902 |
user output |
---|
598246902 |
Test 32
Verdict: ACCEPTED
input |
---|
10000
-1 1 0 -1 2 1 -1 1 -1 0 -1 -1 ... |
correct output |
---|
105842640 |
user output |
---|
105842640 |
Test 33
Verdict: ACCEPTED
input |
---|
10000
0 -1 0 -1 -1 -1 4 3 -1 -1 -1 -... |
correct output |
---|
133310608 |
user output |
---|
133310608 |
Test 34
Verdict: ACCEPTED
input |
---|
10000
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ... |
correct output |
---|
484205143 |
user output |
---|
484205143 |
Test 35
Verdict: ACCEPTED
input |
---|
10000
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ... |
correct output |
---|
904817827 |
user output |
---|
904817827 |
Test 36
Verdict: ACCEPTED
input |
---|
10000
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ... |
correct output |
---|
966971895 |
user output |
---|
966971895 |
Test 37
Verdict: ACCEPTED
input |
---|
10000
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ... |
correct output |
---|
664825423 |
user output |
---|
664825423 |
Test 38
Verdict: ACCEPTED
input |
---|
10000
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ... |
correct output |
---|
681928184 |
user output |
---|
681928184 |