# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
205308 | 2020-02-28T13:44:09 Z | TadijaSebez | Bowling (BOI15_bow) | C++11 | 1000 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){ //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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 174 ms | 888 KB | Output is correct |
2 | Correct | 102 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 | 12 ms | 888 KB | Output is correct |
6 | Correct | 13 ms | 888 KB | Output is correct |
7 | Correct | 270 ms | 888 KB | Output is correct |
8 | Correct | 253 ms | 888 KB | Output is correct |
9 | Correct | 220 ms | 888 KB | Output is correct |
10 | Correct | 243 ms | 888 KB | Output is correct |
11 | Correct | 273 ms | 888 KB | Output is correct |
12 | Correct | 141 ms | 892 KB | Output is correct |
13 | Correct | 35 ms | 888 KB | Output is correct |
14 | Correct | 173 ms | 888 KB | Output is correct |
15 | Correct | 37 ms | 888 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 304 ms | 888 KB | Output is correct |
2 | Correct | 256 ms | 1016 KB | Output is correct |
3 | Correct | 214 ms | 888 KB | Output is correct |
4 | Correct | 189 ms | 888 KB | Output is correct |
5 | Correct | 252 ms | 888 KB | Output is correct |
6 | Correct | 295 ms | 888 KB | Output is correct |
7 | Correct | 323 ms | 888 KB | Output is correct |
8 | Correct | 332 ms | 888 KB | Output is correct |
9 | Correct | 282 ms | 888 KB | Output is correct |
10 | Correct | 609 ms | 1016 KB | Output is correct |
11 | Correct | 659 ms | 892 KB | Output is correct |
12 | Correct | 588 ms | 888 KB | Output is correct |
13 | Correct | 607 ms | 888 KB | Output is correct |
14 | Correct | 308 ms | 888 KB | Output is correct |
15 | Correct | 329 ms | 888 KB | Output is correct |
16 | Correct | 318 ms | 888 KB | Output is correct |
17 | Correct | 311 ms | 888 KB | Output is correct |
18 | Correct | 751 ms | 888 KB | Output is correct |
19 | Correct | 697 ms | 888 KB | Output is correct |
20 | Correct | 747 ms | 888 KB | Output is correct |
21 | Correct | 706 ms | 888 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 161 ms | 888 KB | Output is correct |
2 | Correct | 59 ms | 888 KB | Output is correct |
3 | Correct | 58 ms | 888 KB | Output is correct |
4 | Correct | 69 ms | 888 KB | Output is correct |
5 | Correct | 104 ms | 888 KB | Output is correct |
6 | Correct | 112 ms | 940 KB | Output is correct |
7 | Correct | 90 ms | 888 KB | Output is correct |
8 | Correct | 113 ms | 888 KB | Output is correct |
9 | Correct | 86 ms | 888 KB | Output is correct |
10 | Correct | 100 ms | 888 KB | Output is correct |
11 | Correct | 57 ms | 892 KB | Output is correct |
12 | Correct | 61 ms | 888 KB | Output is correct |
13 | Correct | 61 ms | 888 KB | Output is correct |
14 | Correct | 133 ms | 888 KB | Output is correct |
15 | Correct | 158 ms | 888 KB | Output is correct |
16 | Correct | 162 ms | 888 KB | Output is correct |
17 | Correct | 179 ms | 888 KB | Output is correct |
18 | Correct | 124 ms | 888 KB | Output is correct |
19 | Correct | 136 ms | 888 KB | Output is correct |
20 | Correct | 148 ms | 888 KB | Output is correct |
21 | Correct | 162 ms | 888 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 352 ms | 888 KB | Output is correct |
2 | Correct | 331 ms | 888 KB | Output is correct |
3 | Correct | 365 ms | 888 KB | Output is correct |
4 | Correct | 299 ms | 888 KB | Output is correct |
5 | Correct | 283 ms | 888 KB | Output is correct |
6 | Correct | 231 ms | 888 KB | Output is correct |
7 | Correct | 253 ms | 888 KB | Output is correct |
8 | Correct | 233 ms | 888 KB | Output is correct |
9 | Correct | 255 ms | 888 KB | Output is correct |
10 | Correct | 660 ms | 888 KB | Output is correct |
11 | Correct | 617 ms | 888 KB | Output is correct |
12 | Correct | 596 ms | 1016 KB | Output is correct |
13 | Correct | 583 ms | 892 KB | Output is correct |
14 | Correct | 423 ms | 888 KB | Output is correct |
15 | Correct | 424 ms | 888 KB | Output is correct |
16 | Correct | 401 ms | 888 KB | Output is correct |
17 | Correct | 411 ms | 888 KB | Output is correct |
18 | Correct | 265 ms | 888 KB | Output is correct |
19 | Correct | 236 ms | 888 KB | Output is correct |
20 | Correct | 255 ms | 888 KB | Output is correct |
21 | Correct | 236 ms | 888 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 174 ms | 888 KB | Output is correct |
2 | Correct | 102 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 | 12 ms | 888 KB | Output is correct |
6 | Correct | 13 ms | 888 KB | Output is correct |
7 | Correct | 270 ms | 888 KB | Output is correct |
8 | Correct | 253 ms | 888 KB | Output is correct |
9 | Correct | 220 ms | 888 KB | Output is correct |
10 | Correct | 243 ms | 888 KB | Output is correct |
11 | Correct | 273 ms | 888 KB | Output is correct |
12 | Correct | 141 ms | 892 KB | Output is correct |
13 | Correct | 35 ms | 888 KB | Output is correct |
14 | Correct | 173 ms | 888 KB | Output is correct |
15 | Correct | 37 ms | 888 KB | Output is correct |
16 | Correct | 304 ms | 888 KB | Output is correct |
17 | Correct | 256 ms | 1016 KB | Output is correct |
18 | Correct | 214 ms | 888 KB | Output is correct |
19 | Correct | 189 ms | 888 KB | Output is correct |
20 | Correct | 252 ms | 888 KB | Output is correct |
21 | Correct | 295 ms | 888 KB | Output is correct |
22 | Correct | 323 ms | 888 KB | Output is correct |
23 | Correct | 332 ms | 888 KB | Output is correct |
24 | Correct | 282 ms | 888 KB | Output is correct |
25 | Correct | 609 ms | 1016 KB | Output is correct |
26 | Correct | 659 ms | 892 KB | Output is correct |
27 | Correct | 588 ms | 888 KB | Output is correct |
28 | Correct | 607 ms | 888 KB | Output is correct |
29 | Correct | 308 ms | 888 KB | Output is correct |
30 | Correct | 329 ms | 888 KB | Output is correct |
31 | Correct | 318 ms | 888 KB | Output is correct |
32 | Correct | 311 ms | 888 KB | Output is correct |
33 | Correct | 751 ms | 888 KB | Output is correct |
34 | Correct | 697 ms | 888 KB | Output is correct |
35 | Correct | 747 ms | 888 KB | Output is correct |
36 | Correct | 706 ms | 888 KB | Output is correct |
37 | Correct | 161 ms | 888 KB | Output is correct |
38 | Correct | 59 ms | 888 KB | Output is correct |
39 | Correct | 58 ms | 888 KB | Output is correct |
40 | Correct | 69 ms | 888 KB | Output is correct |
41 | Correct | 104 ms | 888 KB | Output is correct |
42 | Correct | 112 ms | 940 KB | Output is correct |
43 | Correct | 90 ms | 888 KB | Output is correct |
44 | Correct | 113 ms | 888 KB | Output is correct |
45 | Correct | 86 ms | 888 KB | Output is correct |
46 | Correct | 100 ms | 888 KB | Output is correct |
47 | Correct | 57 ms | 892 KB | Output is correct |
48 | Correct | 61 ms | 888 KB | Output is correct |
49 | Correct | 61 ms | 888 KB | Output is correct |
50 | Correct | 133 ms | 888 KB | Output is correct |
51 | Correct | 158 ms | 888 KB | Output is correct |
52 | Correct | 162 ms | 888 KB | Output is correct |
53 | Correct | 179 ms | 888 KB | Output is correct |
54 | Correct | 124 ms | 888 KB | Output is correct |
55 | Correct | 136 ms | 888 KB | Output is correct |
56 | Correct | 148 ms | 888 KB | Output is correct |
57 | Correct | 162 ms | 888 KB | Output is correct |
58 | Correct | 352 ms | 888 KB | Output is correct |
59 | Correct | 331 ms | 888 KB | Output is correct |
60 | Correct | 365 ms | 888 KB | Output is correct |
61 | Correct | 299 ms | 888 KB | Output is correct |
62 | Correct | 283 ms | 888 KB | Output is correct |
63 | Correct | 231 ms | 888 KB | Output is correct |
64 | Correct | 253 ms | 888 KB | Output is correct |
65 | Correct | 233 ms | 888 KB | Output is correct |
66 | Correct | 255 ms | 888 KB | Output is correct |
67 | Correct | 660 ms | 888 KB | Output is correct |
68 | Correct | 617 ms | 888 KB | Output is correct |
69 | Correct | 596 ms | 1016 KB | Output is correct |
70 | Correct | 583 ms | 892 KB | Output is correct |
71 | Correct | 423 ms | 888 KB | Output is correct |
72 | Correct | 424 ms | 888 KB | Output is correct |
73 | Correct | 401 ms | 888 KB | Output is correct |
74 | Correct | 411 ms | 888 KB | Output is correct |
75 | Correct | 265 ms | 888 KB | Output is correct |
76 | Correct | 236 ms | 888 KB | Output is correct |
77 | Correct | 255 ms | 888 KB | Output is correct |
78 | Correct | 236 ms | 888 KB | Output is correct |
79 | Correct | 320 ms | 888 KB | Output is correct |
80 | Correct | 288 ms | 888 KB | Output is correct |
81 | Correct | 242 ms | 888 KB | Output is correct |
82 | Correct | 236 ms | 1016 KB | Output is correct |
83 | Correct | 210 ms | 888 KB | Output is correct |
84 | Correct | 75 ms | 888 KB | Output is correct |
85 | Correct | 104 ms | 1016 KB | Output is correct |
86 | Correct | 72 ms | 888 KB | Output is correct |
87 | Correct | 88 ms | 888 KB | Output is correct |
88 | Correct | 459 ms | 888 KB | Output is correct |
89 | Correct | 580 ms | 888 KB | Output is correct |
90 | Correct | 564 ms | 888 KB | Output is correct |
91 | Correct | 571 ms | 892 KB | Output is correct |
92 | Correct | 312 ms | 888 KB | Output is correct |
93 | Execution timed out | 1097 ms | 888 KB | Time limit exceeded |
94 | Halted | 0 ms | 0 KB | - |