# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
205309 | 2020-02-28T13:46:24 Z | TadijaSebez | Bowling (BOI15_bow) | C++11 | 341 ms | 1016 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const int N=11; const int M=305; int score[N]; ll dp[M][N][N],tmp[M][N][N]; void Clear(){ for(int i=0;i<M;++i) for(int j=0;j<N;++j) for(int k=0;k<N;++k) tmp[i][j][k]=dp[i][j][k],dp[i][j][k]=0; } void Print(int n){ for(int i=0;i<M;++i) for(int j=0;j<N;++j) for(int k=0;k<N;++k) if(dp[i][j][k]) printf("%i %i %i %i %lld\n",n,i,j,k,dp[i][j][k]); } void Solve(){ int n; string str; scanf("%i",&n); cin>>str; for(int i=1;i<=n;i++)scanf("%i",&score[i]); Clear(); for(int i=0;i<M;++i)if(i==score[n] || score[n]==-1){ string now="";now+=str[n*2-2];now+=str[n*2-1];now+=str[n*2]; //Case 1 xxx if((now[0]=='?' || now[0]=='x') && (now[1]=='?' || now[1]=='x') && (now[2]=='?' || now[2]=='x')){ if(i>=30)dp[i-30][10][10]++; } //Case 2 xxA if((now[0]=='?' || now[0]=='x') && (now[1]=='?' || now[1]=='x')){ for(int A=0;A<10;++A)if(now[2]=='?' || now[2]=='0'+A){ if(i>=20+A)dp[i-20-A][10][10]++; } } //Case 3 xA/ if((now[0]=='?' || now[0]=='x') && (now[2]=='?' || now[2]=='/')){ for(int A=0;A<10;++A)if(now[1]=='?' || now[1]=='0'+A){ if(i>=20)dp[i-20][10][A]++; } } //Case 4 xAB if(now[0]=='?' || now[0]=='x'){ for(int A=0;A<10;++A)if(now[1]=='?' || now[1]=='0'+A) for(int B=0;B<10-A;++B)if(now[2]=='?' || now[2]=='0'+B){ if(i>=10+A+B)dp[i-10-A-B][10][A]++; } } //Case 5 A/x if((now[1]=='?' || now[1]=='/') && (now[2]=='?' || now[2]=='x')){ for(int A=0;A<10;++A)if(now[0]=='?' || now[0]=='0'+A){ if(i>=20)dp[i-20][A][10-A]++; } } //Case 6 A/B if(now[1]=='?' || now[1]=='/'){ for(int A=0;A<10;++A)if(now[0]=='?' || now[0]=='0'+A) for(int B=0;B<10;++B)if(now[2]=='?' || now[2]=='0'+B){ if(i>=10+B)dp[i-10-B][A][10-A]++; } } //Case 7 AB- if(now[2]=='-' || now[2]=='?'){ for(int A=0;A<10;++A)if(now[0]=='?' || now[0]=='0'+A) for(int B=0;B<10-A;++B)if(now[1]=='?' || now[1]=='0'+B){ if(i>=A+B)dp[i-A-B][A][B]++; } } } //Print(n); for(int j=n-1;j>=1;--j){ Clear(); string now="";now+=str[j*2-2];now+=str[j*2-1]; for(int i=0;i<M;++i)if(score[j]==i || score[j]==-1){ for(int F=0;F<N;++F)for(int S=0;S<N;++S)if(tmp[i][F][S]){ //Case 1 x- if((now[0]=='?' || now[0]=='x') && (now[1]=='?' || now[1]=='-')){ if(i>=10+F+S)dp[i-10-F-S][10][F]+=tmp[i][F][S]; } //Case 2 A/ if(now[1]=='?' || now[1]=='/'){ for(int A=0;A<10;++A)if(now[0]=='?' || now[0]=='0'+A){ if(i>=10+F)dp[i-10-F][A][10-A]+=tmp[i][F][S]; } } //Case 3 AB for(int A=0;A<10;++A)if(now[0]=='?' || now[0]=='0'+A) for(int B=0;B<10-A;++B)if(now[1]=='?' || now[1]=='0'+B){ if(i>=A+B)dp[i-A-B][A][B]+=tmp[i][F][S]; } } } //Print(j); } ll ans=0; for(int F=0;F<N;++F)for(int S=0;S<N;++S)ans+=dp[0][F][S]; printf("%lld\n",ans); } int main(){ int t;scanf("%i",&t); while(t--)Solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 888 KB | Output is correct |
2 | Correct | 15 ms | 888 KB | Output is correct |
3 | Correct | 11 ms | 888 KB | Output is correct |
4 | Correct | 11 ms | 888 KB | Output is correct |
5 | Correct | 11 ms | 888 KB | Output is correct |
6 | Correct | 13 ms | 888 KB | Output is correct |
7 | Correct | 36 ms | 888 KB | Output is correct |
8 | Correct | 32 ms | 888 KB | Output is correct |
9 | Correct | 30 ms | 892 KB | Output is correct |
10 | Correct | 32 ms | 888 KB | Output is correct |
11 | Correct | 21 ms | 888 KB | Output is correct |
12 | Correct | 8 ms | 888 KB | Output is correct |
13 | Correct | 6 ms | 888 KB | Output is correct |
14 | Correct | 9 ms | 888 KB | Output is correct |
15 | Correct | 6 ms | 888 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 888 KB | Output is correct |
2 | Correct | 29 ms | 888 KB | Output is correct |
3 | Correct | 31 ms | 888 KB | Output is correct |
4 | Correct | 19 ms | 888 KB | Output is correct |
5 | Correct | 33 ms | 888 KB | Output is correct |
6 | Correct | 26 ms | 888 KB | Output is correct |
7 | Correct | 37 ms | 888 KB | Output is correct |
8 | Correct | 31 ms | 888 KB | Output is correct |
9 | Correct | 27 ms | 888 KB | Output is correct |
10 | Correct | 64 ms | 1016 KB | Output is correct |
11 | Correct | 70 ms | 888 KB | Output is correct |
12 | Correct | 77 ms | 888 KB | Output is correct |
13 | Correct | 77 ms | 888 KB | Output is correct |
14 | Correct | 35 ms | 888 KB | Output is correct |
15 | Correct | 39 ms | 888 KB | Output is correct |
16 | Correct | 28 ms | 888 KB | Output is correct |
17 | Correct | 33 ms | 888 KB | Output is correct |
18 | Correct | 116 ms | 888 KB | Output is correct |
19 | Correct | 106 ms | 888 KB | Output is correct |
20 | Correct | 105 ms | 888 KB | Output is correct |
21 | Correct | 121 ms | 888 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 892 KB | Output is correct |
2 | Correct | 13 ms | 888 KB | Output is correct |
3 | Correct | 13 ms | 888 KB | Output is correct |
4 | Correct | 13 ms | 888 KB | Output is correct |
5 | Correct | 13 ms | 888 KB | Output is correct |
6 | Correct | 17 ms | 888 KB | Output is correct |
7 | Correct | 20 ms | 888 KB | Output is correct |
8 | Correct | 17 ms | 888 KB | Output is correct |
9 | Correct | 25 ms | 888 KB | Output is correct |
10 | Correct | 17 ms | 888 KB | Output is correct |
11 | Correct | 16 ms | 888 KB | Output is correct |
12 | Correct | 16 ms | 888 KB | Output is correct |
13 | Correct | 16 ms | 888 KB | Output is correct |
14 | Correct | 19 ms | 888 KB | Output is correct |
15 | Correct | 17 ms | 888 KB | Output is correct |
16 | Correct | 19 ms | 888 KB | Output is correct |
17 | Correct | 19 ms | 892 KB | Output is correct |
18 | Correct | 18 ms | 888 KB | Output is correct |
19 | Correct | 18 ms | 888 KB | Output is correct |
20 | Correct | 18 ms | 888 KB | Output is correct |
21 | Correct | 18 ms | 888 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 91 ms | 888 KB | Output is correct |
2 | Correct | 71 ms | 888 KB | Output is correct |
3 | Correct | 99 ms | 888 KB | Output is correct |
4 | Correct | 78 ms | 888 KB | Output is correct |
5 | Correct | 63 ms | 888 KB | Output is correct |
6 | Correct | 53 ms | 888 KB | Output is correct |
7 | Correct | 72 ms | 888 KB | Output is correct |
8 | Correct | 52 ms | 888 KB | Output is correct |
9 | Correct | 63 ms | 888 KB | Output is correct |
10 | Correct | 259 ms | 936 KB | Output is correct |
11 | Correct | 236 ms | 888 KB | Output is correct |
12 | Correct | 234 ms | 888 KB | Output is correct |
13 | Correct | 252 ms | 888 KB | Output is correct |
14 | Correct | 65 ms | 888 KB | Output is correct |
15 | Correct | 51 ms | 888 KB | Output is correct |
16 | Correct | 59 ms | 888 KB | Output is correct |
17 | Correct | 51 ms | 888 KB | Output is correct |
18 | Correct | 23 ms | 888 KB | Output is correct |
19 | Correct | 36 ms | 888 KB | Output is correct |
20 | Correct | 34 ms | 888 KB | Output is correct |
21 | Correct | 24 ms | 888 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 12 ms | 888 KB | Output is correct |
2 | Correct | 15 ms | 888 KB | Output is correct |
3 | Correct | 11 ms | 888 KB | Output is correct |
4 | Correct | 11 ms | 888 KB | Output is correct |
5 | Correct | 11 ms | 888 KB | Output is correct |
6 | Correct | 13 ms | 888 KB | Output is correct |
7 | Correct | 36 ms | 888 KB | Output is correct |
8 | Correct | 32 ms | 888 KB | Output is correct |
9 | Correct | 30 ms | 892 KB | Output is correct |
10 | Correct | 32 ms | 888 KB | Output is correct |
11 | Correct | 21 ms | 888 KB | Output is correct |
12 | Correct | 8 ms | 888 KB | Output is correct |
13 | Correct | 6 ms | 888 KB | Output is correct |
14 | Correct | 9 ms | 888 KB | Output is correct |
15 | Correct | 6 ms | 888 KB | Output is correct |
16 | Correct | 20 ms | 888 KB | Output is correct |
17 | Correct | 29 ms | 888 KB | Output is correct |
18 | Correct | 31 ms | 888 KB | Output is correct |
19 | Correct | 19 ms | 888 KB | Output is correct |
20 | Correct | 33 ms | 888 KB | Output is correct |
21 | Correct | 26 ms | 888 KB | Output is correct |
22 | Correct | 37 ms | 888 KB | Output is correct |
23 | Correct | 31 ms | 888 KB | Output is correct |
24 | Correct | 27 ms | 888 KB | Output is correct |
25 | Correct | 64 ms | 1016 KB | Output is correct |
26 | Correct | 70 ms | 888 KB | Output is correct |
27 | Correct | 77 ms | 888 KB | Output is correct |
28 | Correct | 77 ms | 888 KB | Output is correct |
29 | Correct | 35 ms | 888 KB | Output is correct |
30 | Correct | 39 ms | 888 KB | Output is correct |
31 | Correct | 28 ms | 888 KB | Output is correct |
32 | Correct | 33 ms | 888 KB | Output is correct |
33 | Correct | 116 ms | 888 KB | Output is correct |
34 | Correct | 106 ms | 888 KB | Output is correct |
35 | Correct | 105 ms | 888 KB | Output is correct |
36 | Correct | 121 ms | 888 KB | Output is correct |
37 | Correct | 12 ms | 892 KB | Output is correct |
38 | Correct | 13 ms | 888 KB | Output is correct |
39 | Correct | 13 ms | 888 KB | Output is correct |
40 | Correct | 13 ms | 888 KB | Output is correct |
41 | Correct | 13 ms | 888 KB | Output is correct |
42 | Correct | 17 ms | 888 KB | Output is correct |
43 | Correct | 20 ms | 888 KB | Output is correct |
44 | Correct | 17 ms | 888 KB | Output is correct |
45 | Correct | 25 ms | 888 KB | Output is correct |
46 | Correct | 17 ms | 888 KB | Output is correct |
47 | Correct | 16 ms | 888 KB | Output is correct |
48 | Correct | 16 ms | 888 KB | Output is correct |
49 | Correct | 16 ms | 888 KB | Output is correct |
50 | Correct | 19 ms | 888 KB | Output is correct |
51 | Correct | 17 ms | 888 KB | Output is correct |
52 | Correct | 19 ms | 888 KB | Output is correct |
53 | Correct | 19 ms | 892 KB | Output is correct |
54 | Correct | 18 ms | 888 KB | Output is correct |
55 | Correct | 18 ms | 888 KB | Output is correct |
56 | Correct | 18 ms | 888 KB | Output is correct |
57 | Correct | 18 ms | 888 KB | Output is correct |
58 | Correct | 91 ms | 888 KB | Output is correct |
59 | Correct | 71 ms | 888 KB | Output is correct |
60 | Correct | 99 ms | 888 KB | Output is correct |
61 | Correct | 78 ms | 888 KB | Output is correct |
62 | Correct | 63 ms | 888 KB | Output is correct |
63 | Correct | 53 ms | 888 KB | Output is correct |
64 | Correct | 72 ms | 888 KB | Output is correct |
65 | Correct | 52 ms | 888 KB | Output is correct |
66 | Correct | 63 ms | 888 KB | Output is correct |
67 | Correct | 259 ms | 936 KB | Output is correct |
68 | Correct | 236 ms | 888 KB | Output is correct |
69 | Correct | 234 ms | 888 KB | Output is correct |
70 | Correct | 252 ms | 888 KB | Output is correct |
71 | Correct | 65 ms | 888 KB | Output is correct |
72 | Correct | 51 ms | 888 KB | Output is correct |
73 | Correct | 59 ms | 888 KB | Output is correct |
74 | Correct | 51 ms | 888 KB | Output is correct |
75 | Correct | 23 ms | 888 KB | Output is correct |
76 | Correct | 36 ms | 888 KB | Output is correct |
77 | Correct | 34 ms | 888 KB | Output is correct |
78 | Correct | 24 ms | 888 KB | Output is correct |
79 | Correct | 108 ms | 888 KB | Output is correct |
80 | Correct | 46 ms | 888 KB | Output is correct |
81 | Correct | 44 ms | 888 KB | Output is correct |
82 | Correct | 27 ms | 888 KB | Output is correct |
83 | Correct | 27 ms | 888 KB | Output is correct |
84 | Correct | 18 ms | 888 KB | Output is correct |
85 | Correct | 20 ms | 888 KB | Output is correct |
86 | Correct | 16 ms | 888 KB | Output is correct |
87 | Correct | 17 ms | 888 KB | Output is correct |
88 | Correct | 34 ms | 888 KB | Output is correct |
89 | Correct | 67 ms | 888 KB | Output is correct |
90 | Correct | 69 ms | 888 KB | Output is correct |
91 | Correct | 74 ms | 888 KB | Output is correct |
92 | Correct | 28 ms | 888 KB | Output is correct |
93 | Correct | 35 ms | 888 KB | Output is correct |
94 | Correct | 86 ms | 888 KB | Output is correct |
95 | Correct | 151 ms | 888 KB | Output is correct |
96 | Correct | 180 ms | 888 KB | Output is correct |
97 | Correct | 326 ms | 888 KB | Output is correct |
98 | Correct | 341 ms | 888 KB | Output is correct |
99 | Correct | 339 ms | 888 KB | Output is correct |
100 | Correct | 338 ms | 888 KB | Output is correct |