Submission #127779

# Submission time Handle Problem Language Result Execution time Memory
127779 2019-07-10T06:00:55 Z tmwilliamlin168 Bowling (BOI15_bow) C++14
100 / 100
766 ms 3708 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

const int mxN=10;
int q, n, a[mxN];
string s;
ll dp[mxN+1][301][11][11];

struct frame {
	vector<int> v;
	int b1, b2;
	string s;
};
vector<frame> vs, vf;

void solve() {
	cin >> n >> s;
	for(int i=0; i<n; ++i)
		cin >> a[i];
	memset(dp, 0, sizeof(dp));
	for(int i=0; i<=10; ++i)
		for(int j=0; j<=10; ++j)
			dp[0][0][i][j]=1;
	for(int i=0; i<n; ++i) {
		for(frame &f : (i<n-1?vs:vf)) {
			bool ok=1;
			for(int k=0; k<f.s.size()&&ok; ++k)
				ok=s[2*i+k]=='?'||s[2*i+k]==f.s[k];
			if(!ok)
				continue;
			for(int j=0; j<=300; ++j) {
				int bs=j;
				for(int b : f.v)
					bs+=b;
				for(int k=0; k<=10; ++k) {
					if(k^f.v[0])
						continue;
					for(int l=0; l<=10; ++l) {
						if((f.v.size()>1&&l^f.v[1])||!dp[i][j][k][l])
							continue;
						for(int k2=0; k2<=10; ++k2) {
							if(f.v.size()<2&&k2^l)
								continue;
							for(int l2=0; l2<=10; ++l2) {
								int j2=bs+f.b1*k2+f.b2*l2;
								if(a[i]<0||a[i]==j2)
									dp[i+1][j2][k2][l2]+=dp[i][j][k][l];
							}
						}
					}
				}
			}
		}
	}
	ll ans=0;
	for(int i=0; i<=300; ++i)
		ans+=dp[n][i][0][0];
	cout << ans << "\n";
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	vs.push_back({{10}, 1, 1, "x-"});
	for(int i=0; i<10; ++i)
		vs.push_back({{i, 10-i}, 1, 0, to_string(i)+"/"});
	for(int i=0; i<10; ++i)
		for(int j=0; j<10-i; ++j)
			vs.push_back({{i, j}, 0, 0, to_string(i)+to_string(j)});
	vf.push_back({{10, 10, 10}, 0, 0, "xxx"});
	for(int i=0; i<10; ++i)
		vf.push_back({{10, 10, i}, 0, 0, "xx"+to_string(i)});
	for(int i=0; i<10; ++i)
		vf.push_back({{10, i, 10-i}, 0, 0, "x"+to_string(i)+"/"});
	for(int i=0; i<10; ++i)
		for(int j=0; j<10-i; ++j)
			vf.push_back({{10, i, j}, 0, 0, "x"+to_string(i)+to_string(j)});
	for(int i=0; i<10; ++i)
		vf.push_back({{i, 10-i, 10}, 0, 0, to_string(i)+"/x"});
	for(int i=0; i<10; ++i)
		for(int j=0; j<10; ++j)
			vf.push_back({{i, 10-i, j}, 0, 0, to_string(i)+"/"+to_string(j)});
	for(int i=0; i<10; ++i)
		for(int j=0; j<10-i; ++j)
			vf.push_back({{i, j}, 0, 0, to_string(i)+to_string(j)+"-"});
	cin >> q;
	while(q--)
		solve();
}

Compilation message

bow.cpp: In function 'void solve()':
bow.cpp:29:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int k=0; k<f.s.size()&&ok; ++k)
                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 49 ms 3580 KB Output is correct
2 Correct 30 ms 3704 KB Output is correct
3 Correct 21 ms 3576 KB Output is correct
4 Correct 34 ms 3448 KB Output is correct
5 Correct 30 ms 3592 KB Output is correct
6 Correct 26 ms 3448 KB Output is correct
7 Correct 28 ms 3576 KB Output is correct
8 Correct 34 ms 3576 KB Output is correct
9 Correct 28 ms 3448 KB Output is correct
10 Correct 27 ms 3576 KB Output is correct
11 Correct 33 ms 3576 KB Output is correct
12 Correct 110 ms 3448 KB Output is correct
13 Correct 27 ms 3704 KB Output is correct
14 Correct 108 ms 3448 KB Output is correct
15 Correct 29 ms 3452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 3576 KB Output is correct
2 Correct 103 ms 3556 KB Output is correct
3 Correct 95 ms 3452 KB Output is correct
4 Correct 84 ms 3552 KB Output is correct
5 Correct 116 ms 3576 KB Output is correct
6 Correct 98 ms 3576 KB Output is correct
7 Correct 107 ms 3676 KB Output is correct
8 Correct 91 ms 3576 KB Output is correct
9 Correct 91 ms 3596 KB Output is correct
10 Correct 234 ms 3576 KB Output is correct
11 Correct 260 ms 3576 KB Output is correct
12 Correct 235 ms 3448 KB Output is correct
13 Correct 265 ms 3576 KB Output is correct
14 Correct 265 ms 3448 KB Output is correct
15 Correct 257 ms 3576 KB Output is correct
16 Correct 277 ms 3576 KB Output is correct
17 Correct 263 ms 3560 KB Output is correct
18 Correct 206 ms 3576 KB Output is correct
19 Correct 195 ms 3576 KB Output is correct
20 Correct 256 ms 3596 KB Output is correct
21 Correct 228 ms 3580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 3576 KB Output is correct
2 Correct 84 ms 3576 KB Output is correct
3 Correct 85 ms 3576 KB Output is correct
4 Correct 64 ms 3448 KB Output is correct
5 Correct 56 ms 3580 KB Output is correct
6 Correct 90 ms 3580 KB Output is correct
7 Correct 112 ms 3448 KB Output is correct
8 Correct 87 ms 3576 KB Output is correct
9 Correct 113 ms 3448 KB Output is correct
10 Correct 255 ms 3576 KB Output is correct
11 Correct 254 ms 3576 KB Output is correct
12 Correct 261 ms 3592 KB Output is correct
13 Correct 259 ms 3588 KB Output is correct
14 Correct 223 ms 3576 KB Output is correct
15 Correct 222 ms 3660 KB Output is correct
16 Correct 220 ms 3592 KB Output is correct
17 Correct 220 ms 3588 KB Output is correct
18 Correct 43 ms 3576 KB Output is correct
19 Correct 42 ms 3576 KB Output is correct
20 Correct 43 ms 3576 KB Output is correct
21 Correct 31 ms 3448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 3448 KB Output is correct
2 Correct 68 ms 3580 KB Output is correct
3 Correct 88 ms 3708 KB Output is correct
4 Correct 65 ms 3624 KB Output is correct
5 Correct 64 ms 3576 KB Output is correct
6 Correct 60 ms 3676 KB Output is correct
7 Correct 65 ms 3576 KB Output is correct
8 Correct 62 ms 3576 KB Output is correct
9 Correct 68 ms 3576 KB Output is correct
10 Correct 171 ms 3588 KB Output is correct
11 Correct 168 ms 3576 KB Output is correct
12 Correct 156 ms 3576 KB Output is correct
13 Correct 159 ms 3556 KB Output is correct
14 Correct 72 ms 3448 KB Output is correct
15 Correct 70 ms 3448 KB Output is correct
16 Correct 87 ms 3556 KB Output is correct
17 Correct 89 ms 3556 KB Output is correct
18 Correct 32 ms 3448 KB Output is correct
19 Correct 34 ms 3576 KB Output is correct
20 Correct 29 ms 3448 KB Output is correct
21 Correct 24 ms 3452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 3580 KB Output is correct
2 Correct 30 ms 3704 KB Output is correct
3 Correct 21 ms 3576 KB Output is correct
4 Correct 34 ms 3448 KB Output is correct
5 Correct 30 ms 3592 KB Output is correct
6 Correct 26 ms 3448 KB Output is correct
7 Correct 28 ms 3576 KB Output is correct
8 Correct 34 ms 3576 KB Output is correct
9 Correct 28 ms 3448 KB Output is correct
10 Correct 27 ms 3576 KB Output is correct
11 Correct 33 ms 3576 KB Output is correct
12 Correct 110 ms 3448 KB Output is correct
13 Correct 27 ms 3704 KB Output is correct
14 Correct 108 ms 3448 KB Output is correct
15 Correct 29 ms 3452 KB Output is correct
16 Correct 66 ms 3576 KB Output is correct
17 Correct 103 ms 3556 KB Output is correct
18 Correct 95 ms 3452 KB Output is correct
19 Correct 84 ms 3552 KB Output is correct
20 Correct 116 ms 3576 KB Output is correct
21 Correct 98 ms 3576 KB Output is correct
22 Correct 107 ms 3676 KB Output is correct
23 Correct 91 ms 3576 KB Output is correct
24 Correct 91 ms 3596 KB Output is correct
25 Correct 234 ms 3576 KB Output is correct
26 Correct 260 ms 3576 KB Output is correct
27 Correct 235 ms 3448 KB Output is correct
28 Correct 265 ms 3576 KB Output is correct
29 Correct 265 ms 3448 KB Output is correct
30 Correct 257 ms 3576 KB Output is correct
31 Correct 277 ms 3576 KB Output is correct
32 Correct 263 ms 3560 KB Output is correct
33 Correct 206 ms 3576 KB Output is correct
34 Correct 195 ms 3576 KB Output is correct
35 Correct 256 ms 3596 KB Output is correct
36 Correct 228 ms 3580 KB Output is correct
37 Correct 73 ms 3576 KB Output is correct
38 Correct 84 ms 3576 KB Output is correct
39 Correct 85 ms 3576 KB Output is correct
40 Correct 64 ms 3448 KB Output is correct
41 Correct 56 ms 3580 KB Output is correct
42 Correct 90 ms 3580 KB Output is correct
43 Correct 112 ms 3448 KB Output is correct
44 Correct 87 ms 3576 KB Output is correct
45 Correct 113 ms 3448 KB Output is correct
46 Correct 255 ms 3576 KB Output is correct
47 Correct 254 ms 3576 KB Output is correct
48 Correct 261 ms 3592 KB Output is correct
49 Correct 259 ms 3588 KB Output is correct
50 Correct 223 ms 3576 KB Output is correct
51 Correct 222 ms 3660 KB Output is correct
52 Correct 220 ms 3592 KB Output is correct
53 Correct 220 ms 3588 KB Output is correct
54 Correct 43 ms 3576 KB Output is correct
55 Correct 42 ms 3576 KB Output is correct
56 Correct 43 ms 3576 KB Output is correct
57 Correct 31 ms 3448 KB Output is correct
58 Correct 91 ms 3448 KB Output is correct
59 Correct 68 ms 3580 KB Output is correct
60 Correct 88 ms 3708 KB Output is correct
61 Correct 65 ms 3624 KB Output is correct
62 Correct 64 ms 3576 KB Output is correct
63 Correct 60 ms 3676 KB Output is correct
64 Correct 65 ms 3576 KB Output is correct
65 Correct 62 ms 3576 KB Output is correct
66 Correct 68 ms 3576 KB Output is correct
67 Correct 171 ms 3588 KB Output is correct
68 Correct 168 ms 3576 KB Output is correct
69 Correct 156 ms 3576 KB Output is correct
70 Correct 159 ms 3556 KB Output is correct
71 Correct 72 ms 3448 KB Output is correct
72 Correct 70 ms 3448 KB Output is correct
73 Correct 87 ms 3556 KB Output is correct
74 Correct 89 ms 3556 KB Output is correct
75 Correct 32 ms 3448 KB Output is correct
76 Correct 34 ms 3576 KB Output is correct
77 Correct 29 ms 3448 KB Output is correct
78 Correct 24 ms 3452 KB Output is correct
79 Correct 119 ms 3576 KB Output is correct
80 Correct 151 ms 3576 KB Output is correct
81 Correct 134 ms 3600 KB Output is correct
82 Correct 103 ms 3556 KB Output is correct
83 Correct 104 ms 3592 KB Output is correct
84 Correct 174 ms 3576 KB Output is correct
85 Correct 224 ms 3648 KB Output is correct
86 Correct 177 ms 3576 KB Output is correct
87 Correct 201 ms 3448 KB Output is correct
88 Correct 219 ms 3576 KB Output is correct
89 Correct 245 ms 3576 KB Output is correct
90 Correct 233 ms 3576 KB Output is correct
91 Correct 233 ms 3576 KB Output is correct
92 Correct 19 ms 3576 KB Output is correct
93 Correct 753 ms 3576 KB Output is correct
94 Correct 754 ms 3448 KB Output is correct
95 Correct 757 ms 3576 KB Output is correct
96 Correct 760 ms 3556 KB Output is correct
97 Correct 750 ms 3576 KB Output is correct
98 Correct 766 ms 3576 KB Output is correct
99 Correct 749 ms 3576 KB Output is correct
100 Correct 752 ms 3576 KB Output is correct