# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
656189 | 2022-11-06T13:09:54 Z | kinope | Bowling (BOI15_bow) | C++14 | 577 ms | 972 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll dp[302][11][11], dp2[302][11][11]; int p[11]; void Clear(){ for(int i = 0; i < 301; ++i) for(int j = 0; j < 11; ++j) for(int k = 0; k < 11; ++k) dp2[i][j][k]=0, dp[i][j][k]=0; } void Copy(){ for(int i = 0; i < 301; ++i) for(int j = 0; j < 11; ++j) for(int k = 0; k < 11; ++k) dp2[i][j][k]=dp[i][j][k], dp[i][j][k]=0; } void rozw(){ int n; string s=""; char c; scanf("%d\n", &n); for(int i = 0; i <= n<<1; ++i) c = getchar_unlocked(), s+=c; //cin >> s; for(int i = 1; i <= n; ++i) scanf("%d", &p[i]); Clear(); for(int pkt = 301; ~pkt; --pkt) if(pkt==p[n]||p[n]==-1){ char t[3] = {s[n*2-2], s[n*2-1], s[n*2]}; //xxx if(pkt-30>=0) if((t[0]=='x'||t[0]=='?') && (t[1]=='x'||t[1]=='?') && (t[2]=='x'||t[2]=='?')) ++dp[pkt-30][10][10]; //xxA for(int A = 0; A < 10; ++A) if(pkt-20-A>=0) if((t[0]=='x'||t[0]=='?') && (t[1]=='x'||t[1]=='?') && (t[2]=='0'+A||t[2]=='?')) ++dp[pkt-20-A][10][10]; //xA/ for(int A = 0; A < 10; ++A) if(pkt-20>=0) if((t[0]=='x'||t[0]=='?') && (t[1]=='0'+A||t[1]=='?') && (t[2]=='/'||t[2]=='?')) ++dp[pkt-20][10][A]; //xAB for(int A = 0; A < 10; ++A) for(int B = 0; B < 10-A; ++B) if(pkt-10-A-B>=0) if((t[0]=='x'||t[0]=='?') && (t[1]=='0'+A||t[1]=='?') && (t[2]=='0'+B||t[2]=='?')) ++dp[pkt-10-A-B][10][A]; //A/x for(int A = 0; A < 10; ++A) if(pkt-20>=0) if((t[0]=='0'+A||t[0]=='?') && (t[1]=='/'||t[1]=='?') && (t[2]=='x'||t[2]=='?')) ++dp[pkt-20][A][10-A]; //A/B for(int A = 0; A < 10; ++A) for(int B = 0; B < 10; ++B) if(pkt-10-B>=0) if((t[0]=='0'+A||t[0]=='?') && (t[1]=='/'||t[1]=='?') && (t[2]=='0'+B||t[2]=='?')) ++dp[pkt-10-B][A][10-A]; //AB- for(int A = 0; A < 10; ++A) for(int B = 0; B < 10-A; ++B) if(pkt-A-B>=0) if((t[0]=='0'+A||t[0]=='?') && (t[1]=='0'+B||t[1]=='?') && (t[2]=='-'||t[2]=='?')) {++dp[pkt-A-B][A][B];} } for(--n; n; --n){ Copy(); for(int pkt = n*30; ~pkt; --pkt) if(pkt==p[n]||p[n]==-1){ char t[2] = {s[n*2-2], s[n*2-1]}; //x- for(int A = 0; A <= 10; ++A) for(int B = 0; B <= 10; ++B) if(pkt-10-A-B>=0) if((t[0]=='x'||t[0]=='?') && (t[1]=='-'||t[1]=='?')) dp[pkt-10-A-B][10][A] += dp2[pkt][A][B]; //A/ for(int A = 0; A < 10; ++A) for(int B = 0; B <= 10; ++B) if(pkt-10-B>=0) for(int C = 0; C <= 10; ++C) if((t[0]=='0'+A||t[0]=='?') && (t[1]=='/'||t[1]=='?')) dp[pkt-10-B][A][10-A] += dp2[pkt][B][C]; //AB for(int A = 0; A < 10; ++A) for(int B = 0; B < 10-A; ++B) if(pkt-A-B>=0) for(int C = 0; C <= 10; ++C) for(int D = 0; D <= 10; ++D) if((t[0]=='0'+A||t[0]=='?') && (t[1]=='0'+B||t[1]=='?')) dp[pkt-A-B][A][B] += dp2[pkt][C][D]; } } ll wynik = 0; for(int A = 0; A <= 10; ++A) for(int B = 0; B <= 10; ++B) wynik += dp[0][A][B]; printf("%lld\n", wynik); } int main(){ int q; scanf("%d", &q); for(++q; --q; ) rozw(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 53 ms | 852 KB | Output is correct |
2 | Correct | 45 ms | 860 KB | Output is correct |
3 | Correct | 7 ms | 816 KB | Output is correct |
4 | Correct | 7 ms | 852 KB | Output is correct |
5 | Correct | 7 ms | 876 KB | Output is correct |
6 | Correct | 8 ms | 852 KB | Output is correct |
7 | Correct | 146 ms | 852 KB | Output is correct |
8 | Correct | 123 ms | 864 KB | Output is correct |
9 | Correct | 95 ms | 852 KB | Output is correct |
10 | Correct | 119 ms | 852 KB | Output is correct |
11 | Correct | 171 ms | 852 KB | Output is correct |
12 | Correct | 12 ms | 852 KB | Output is correct |
13 | Correct | 3 ms | 852 KB | Output is correct |
14 | Correct | 15 ms | 876 KB | Output is correct |
15 | Correct | 4 ms | 852 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 123 ms | 852 KB | Output is correct |
2 | Correct | 85 ms | 868 KB | Output is correct |
3 | Correct | 77 ms | 860 KB | Output is correct |
4 | Correct | 69 ms | 860 KB | Output is correct |
5 | Correct | 87 ms | 880 KB | Output is correct |
6 | Correct | 163 ms | 860 KB | Output is correct |
7 | Correct | 166 ms | 972 KB | Output is correct |
8 | Correct | 177 ms | 852 KB | Output is correct |
9 | Correct | 161 ms | 864 KB | Output is correct |
10 | Correct | 274 ms | 856 KB | Output is correct |
11 | Correct | 300 ms | 856 KB | Output is correct |
12 | Correct | 263 ms | 860 KB | Output is correct |
13 | Correct | 256 ms | 856 KB | Output is correct |
14 | Correct | 156 ms | 852 KB | Output is correct |
15 | Correct | 152 ms | 852 KB | Output is correct |
16 | Correct | 132 ms | 856 KB | Output is correct |
17 | Correct | 135 ms | 852 KB | Output is correct |
18 | Correct | 355 ms | 864 KB | Output is correct |
19 | Correct | 347 ms | 972 KB | Output is correct |
20 | Correct | 367 ms | 864 KB | Output is correct |
21 | Correct | 356 ms | 856 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 62 ms | 852 KB | Output is correct |
2 | Correct | 30 ms | 852 KB | Output is correct |
3 | Correct | 28 ms | 852 KB | Output is correct |
4 | Correct | 37 ms | 852 KB | Output is correct |
5 | Correct | 43 ms | 852 KB | Output is correct |
6 | Correct | 51 ms | 852 KB | Output is correct |
7 | Correct | 42 ms | 852 KB | Output is correct |
8 | Correct | 65 ms | 852 KB | Output is correct |
9 | Correct | 45 ms | 852 KB | Output is correct |
10 | Correct | 49 ms | 860 KB | Output is correct |
11 | Correct | 36 ms | 972 KB | Output is correct |
12 | Correct | 39 ms | 852 KB | Output is correct |
13 | Correct | 32 ms | 852 KB | Output is correct |
14 | Correct | 51 ms | 856 KB | Output is correct |
15 | Correct | 73 ms | 852 KB | Output is correct |
16 | Correct | 81 ms | 852 KB | Output is correct |
17 | Correct | 83 ms | 856 KB | Output is correct |
18 | Correct | 90 ms | 868 KB | Output is correct |
19 | Correct | 99 ms | 852 KB | Output is correct |
20 | Correct | 102 ms | 872 KB | Output is correct |
21 | Correct | 109 ms | 852 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 181 ms | 852 KB | Output is correct |
2 | Correct | 112 ms | 868 KB | Output is correct |
3 | Correct | 149 ms | 868 KB | Output is correct |
4 | Correct | 110 ms | 852 KB | Output is correct |
5 | Correct | 109 ms | 876 KB | Output is correct |
6 | Correct | 100 ms | 856 KB | Output is correct |
7 | Correct | 96 ms | 852 KB | Output is correct |
8 | Correct | 102 ms | 868 KB | Output is correct |
9 | Correct | 107 ms | 856 KB | Output is correct |
10 | Correct | 263 ms | 852 KB | Output is correct |
11 | Correct | 217 ms | 852 KB | Output is correct |
12 | Correct | 210 ms | 852 KB | Output is correct |
13 | Correct | 196 ms | 872 KB | Output is correct |
14 | Correct | 259 ms | 856 KB | Output is correct |
15 | Correct | 225 ms | 872 KB | Output is correct |
16 | Correct | 219 ms | 852 KB | Output is correct |
17 | Correct | 245 ms | 856 KB | Output is correct |
18 | Correct | 177 ms | 860 KB | Output is correct |
19 | Correct | 196 ms | 856 KB | Output is correct |
20 | Correct | 180 ms | 852 KB | Output is correct |
21 | Correct | 173 ms | 872 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 53 ms | 852 KB | Output is correct |
2 | Correct | 45 ms | 860 KB | Output is correct |
3 | Correct | 7 ms | 816 KB | Output is correct |
4 | Correct | 7 ms | 852 KB | Output is correct |
5 | Correct | 7 ms | 876 KB | Output is correct |
6 | Correct | 8 ms | 852 KB | Output is correct |
7 | Correct | 146 ms | 852 KB | Output is correct |
8 | Correct | 123 ms | 864 KB | Output is correct |
9 | Correct | 95 ms | 852 KB | Output is correct |
10 | Correct | 119 ms | 852 KB | Output is correct |
11 | Correct | 171 ms | 852 KB | Output is correct |
12 | Correct | 12 ms | 852 KB | Output is correct |
13 | Correct | 3 ms | 852 KB | Output is correct |
14 | Correct | 15 ms | 876 KB | Output is correct |
15 | Correct | 4 ms | 852 KB | Output is correct |
16 | Correct | 123 ms | 852 KB | Output is correct |
17 | Correct | 85 ms | 868 KB | Output is correct |
18 | Correct | 77 ms | 860 KB | Output is correct |
19 | Correct | 69 ms | 860 KB | Output is correct |
20 | Correct | 87 ms | 880 KB | Output is correct |
21 | Correct | 163 ms | 860 KB | Output is correct |
22 | Correct | 166 ms | 972 KB | Output is correct |
23 | Correct | 177 ms | 852 KB | Output is correct |
24 | Correct | 161 ms | 864 KB | Output is correct |
25 | Correct | 274 ms | 856 KB | Output is correct |
26 | Correct | 300 ms | 856 KB | Output is correct |
27 | Correct | 263 ms | 860 KB | Output is correct |
28 | Correct | 256 ms | 856 KB | Output is correct |
29 | Correct | 156 ms | 852 KB | Output is correct |
30 | Correct | 152 ms | 852 KB | Output is correct |
31 | Correct | 132 ms | 856 KB | Output is correct |
32 | Correct | 135 ms | 852 KB | Output is correct |
33 | Correct | 355 ms | 864 KB | Output is correct |
34 | Correct | 347 ms | 972 KB | Output is correct |
35 | Correct | 367 ms | 864 KB | Output is correct |
36 | Correct | 356 ms | 856 KB | Output is correct |
37 | Correct | 62 ms | 852 KB | Output is correct |
38 | Correct | 30 ms | 852 KB | Output is correct |
39 | Correct | 28 ms | 852 KB | Output is correct |
40 | Correct | 37 ms | 852 KB | Output is correct |
41 | Correct | 43 ms | 852 KB | Output is correct |
42 | Correct | 51 ms | 852 KB | Output is correct |
43 | Correct | 42 ms | 852 KB | Output is correct |
44 | Correct | 65 ms | 852 KB | Output is correct |
45 | Correct | 45 ms | 852 KB | Output is correct |
46 | Correct | 49 ms | 860 KB | Output is correct |
47 | Correct | 36 ms | 972 KB | Output is correct |
48 | Correct | 39 ms | 852 KB | Output is correct |
49 | Correct | 32 ms | 852 KB | Output is correct |
50 | Correct | 51 ms | 856 KB | Output is correct |
51 | Correct | 73 ms | 852 KB | Output is correct |
52 | Correct | 81 ms | 852 KB | Output is correct |
53 | Correct | 83 ms | 856 KB | Output is correct |
54 | Correct | 90 ms | 868 KB | Output is correct |
55 | Correct | 99 ms | 852 KB | Output is correct |
56 | Correct | 102 ms | 872 KB | Output is correct |
57 | Correct | 109 ms | 852 KB | Output is correct |
58 | Correct | 181 ms | 852 KB | Output is correct |
59 | Correct | 112 ms | 868 KB | Output is correct |
60 | Correct | 149 ms | 868 KB | Output is correct |
61 | Correct | 110 ms | 852 KB | Output is correct |
62 | Correct | 109 ms | 876 KB | Output is correct |
63 | Correct | 100 ms | 856 KB | Output is correct |
64 | Correct | 96 ms | 852 KB | Output is correct |
65 | Correct | 102 ms | 868 KB | Output is correct |
66 | Correct | 107 ms | 856 KB | Output is correct |
67 | Correct | 263 ms | 852 KB | Output is correct |
68 | Correct | 217 ms | 852 KB | Output is correct |
69 | Correct | 210 ms | 852 KB | Output is correct |
70 | Correct | 196 ms | 872 KB | Output is correct |
71 | Correct | 259 ms | 856 KB | Output is correct |
72 | Correct | 225 ms | 872 KB | Output is correct |
73 | Correct | 219 ms | 852 KB | Output is correct |
74 | Correct | 245 ms | 856 KB | Output is correct |
75 | Correct | 177 ms | 860 KB | Output is correct |
76 | Correct | 196 ms | 856 KB | Output is correct |
77 | Correct | 180 ms | 852 KB | Output is correct |
78 | Correct | 173 ms | 872 KB | Output is correct |
79 | Correct | 147 ms | 852 KB | Output is correct |
80 | Correct | 104 ms | 856 KB | Output is correct |
81 | Correct | 88 ms | 860 KB | Output is correct |
82 | Correct | 94 ms | 860 KB | Output is correct |
83 | Correct | 72 ms | 856 KB | Output is correct |
84 | Correct | 44 ms | 852 KB | Output is correct |
85 | Correct | 50 ms | 852 KB | Output is correct |
86 | Correct | 34 ms | 876 KB | Output is correct |
87 | Correct | 39 ms | 852 KB | Output is correct |
88 | Correct | 215 ms | 860 KB | Output is correct |
89 | Correct | 272 ms | 860 KB | Output is correct |
90 | Correct | 264 ms | 856 KB | Output is correct |
91 | Correct | 267 ms | 972 KB | Output is correct |
92 | Correct | 222 ms | 876 KB | Output is correct |
93 | Correct | 556 ms | 972 KB | Output is correct |
94 | Correct | 554 ms | 860 KB | Output is correct |
95 | Correct | 545 ms | 856 KB | Output is correct |
96 | Correct | 546 ms | 972 KB | Output is correct |
97 | Correct | 553 ms | 860 KB | Output is correct |
98 | Correct | 544 ms | 904 KB | Output is correct |
99 | Correct | 543 ms | 864 KB | Output is correct |
100 | Correct | 577 ms | 860 KB | Output is correct |