Submission #127735

# Submission time Handle Problem Language Result Execution time Memory
127735 2019-07-10T04:29:17 Z tmwilliamlin168 Bowling (BOI15_bow) C++14
82 / 100
1000 ms 3704 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(int j=0; j<=300; ++j) {
			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;
				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:30:19: 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 213 ms 3576 KB Output is correct
2 Correct 219 ms 3576 KB Output is correct
3 Correct 218 ms 3576 KB Output is correct
4 Correct 244 ms 3576 KB Output is correct
5 Correct 261 ms 3576 KB Output is correct
6 Correct 246 ms 3624 KB Output is correct
7 Correct 298 ms 3576 KB Output is correct
8 Correct 257 ms 3576 KB Output is correct
9 Correct 230 ms 3576 KB Output is correct
10 Correct 253 ms 3576 KB Output is correct
11 Correct 359 ms 3704 KB Output is correct
12 Correct 242 ms 3576 KB Output is correct
13 Correct 52 ms 3576 KB Output is correct
14 Correct 239 ms 3676 KB Output is correct
15 Correct 60 ms 3576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 213 ms 3560 KB Output is correct
2 Correct 325 ms 3556 KB Output is correct
3 Correct 319 ms 3576 KB Output is correct
4 Correct 315 ms 3576 KB Output is correct
5 Correct 348 ms 3576 KB Output is correct
6 Correct 399 ms 3608 KB Output is correct
7 Correct 416 ms 3448 KB Output is correct
8 Correct 397 ms 3500 KB Output is correct
9 Correct 396 ms 3448 KB Output is correct
10 Correct 543 ms 3576 KB Output is correct
11 Correct 565 ms 3448 KB Output is correct
12 Correct 551 ms 3448 KB Output is correct
13 Correct 575 ms 3448 KB Output is correct
14 Correct 583 ms 3448 KB Output is correct
15 Correct 579 ms 3576 KB Output is correct
16 Correct 609 ms 3704 KB Output is correct
17 Correct 587 ms 3448 KB Output is correct
18 Correct 553 ms 3576 KB Output is correct
19 Correct 537 ms 3704 KB Output is correct
20 Correct 594 ms 3576 KB Output is correct
21 Correct 568 ms 3576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 160 ms 3448 KB Output is correct
2 Correct 322 ms 3676 KB Output is correct
3 Correct 317 ms 3448 KB Output is correct
4 Correct 284 ms 3576 KB Output is correct
5 Correct 262 ms 3576 KB Output is correct
6 Correct 420 ms 3576 KB Output is correct
7 Correct 427 ms 3576 KB Output is correct
8 Correct 400 ms 3448 KB Output is correct
9 Correct 447 ms 3576 KB Output is correct
10 Correct 582 ms 3676 KB Output is correct
11 Correct 572 ms 3576 KB Output is correct
12 Correct 593 ms 3592 KB Output is correct
13 Correct 584 ms 3704 KB Output is correct
14 Correct 538 ms 3576 KB Output is correct
15 Correct 553 ms 3576 KB Output is correct
16 Correct 536 ms 3452 KB Output is correct
17 Correct 535 ms 3576 KB Output is correct
18 Correct 365 ms 3576 KB Output is correct
19 Correct 365 ms 3576 KB Output is correct
20 Correct 362 ms 3448 KB Output is correct
21 Correct 392 ms 3576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 266 ms 3564 KB Output is correct
2 Correct 269 ms 3560 KB Output is correct
3 Correct 304 ms 3576 KB Output is correct
4 Correct 268 ms 3576 KB Output is correct
5 Correct 265 ms 3704 KB Output is correct
6 Correct 280 ms 3580 KB Output is correct
7 Correct 273 ms 3576 KB Output is correct
8 Correct 264 ms 3516 KB Output is correct
9 Correct 281 ms 3560 KB Output is correct
10 Correct 430 ms 3576 KB Output is correct
11 Correct 405 ms 3564 KB Output is correct
12 Correct 398 ms 3576 KB Output is correct
13 Correct 379 ms 3576 KB Output is correct
14 Correct 382 ms 3596 KB Output is correct
15 Correct 378 ms 3704 KB Output is correct
16 Correct 398 ms 3576 KB Output is correct
17 Correct 410 ms 3704 KB Output is correct
18 Correct 334 ms 3576 KB Output is correct
19 Correct 346 ms 3704 KB Output is correct
20 Correct 351 ms 3576 KB Output is correct
21 Correct 326 ms 3576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 213 ms 3576 KB Output is correct
2 Correct 219 ms 3576 KB Output is correct
3 Correct 218 ms 3576 KB Output is correct
4 Correct 244 ms 3576 KB Output is correct
5 Correct 261 ms 3576 KB Output is correct
6 Correct 246 ms 3624 KB Output is correct
7 Correct 298 ms 3576 KB Output is correct
8 Correct 257 ms 3576 KB Output is correct
9 Correct 230 ms 3576 KB Output is correct
10 Correct 253 ms 3576 KB Output is correct
11 Correct 359 ms 3704 KB Output is correct
12 Correct 242 ms 3576 KB Output is correct
13 Correct 52 ms 3576 KB Output is correct
14 Correct 239 ms 3676 KB Output is correct
15 Correct 60 ms 3576 KB Output is correct
16 Correct 213 ms 3560 KB Output is correct
17 Correct 325 ms 3556 KB Output is correct
18 Correct 319 ms 3576 KB Output is correct
19 Correct 315 ms 3576 KB Output is correct
20 Correct 348 ms 3576 KB Output is correct
21 Correct 399 ms 3608 KB Output is correct
22 Correct 416 ms 3448 KB Output is correct
23 Correct 397 ms 3500 KB Output is correct
24 Correct 396 ms 3448 KB Output is correct
25 Correct 543 ms 3576 KB Output is correct
26 Correct 565 ms 3448 KB Output is correct
27 Correct 551 ms 3448 KB Output is correct
28 Correct 575 ms 3448 KB Output is correct
29 Correct 583 ms 3448 KB Output is correct
30 Correct 579 ms 3576 KB Output is correct
31 Correct 609 ms 3704 KB Output is correct
32 Correct 587 ms 3448 KB Output is correct
33 Correct 553 ms 3576 KB Output is correct
34 Correct 537 ms 3704 KB Output is correct
35 Correct 594 ms 3576 KB Output is correct
36 Correct 568 ms 3576 KB Output is correct
37 Correct 160 ms 3448 KB Output is correct
38 Correct 322 ms 3676 KB Output is correct
39 Correct 317 ms 3448 KB Output is correct
40 Correct 284 ms 3576 KB Output is correct
41 Correct 262 ms 3576 KB Output is correct
42 Correct 420 ms 3576 KB Output is correct
43 Correct 427 ms 3576 KB Output is correct
44 Correct 400 ms 3448 KB Output is correct
45 Correct 447 ms 3576 KB Output is correct
46 Correct 582 ms 3676 KB Output is correct
47 Correct 572 ms 3576 KB Output is correct
48 Correct 593 ms 3592 KB Output is correct
49 Correct 584 ms 3704 KB Output is correct
50 Correct 538 ms 3576 KB Output is correct
51 Correct 553 ms 3576 KB Output is correct
52 Correct 536 ms 3452 KB Output is correct
53 Correct 535 ms 3576 KB Output is correct
54 Correct 365 ms 3576 KB Output is correct
55 Correct 365 ms 3576 KB Output is correct
56 Correct 362 ms 3448 KB Output is correct
57 Correct 392 ms 3576 KB Output is correct
58 Correct 266 ms 3564 KB Output is correct
59 Correct 269 ms 3560 KB Output is correct
60 Correct 304 ms 3576 KB Output is correct
61 Correct 268 ms 3576 KB Output is correct
62 Correct 265 ms 3704 KB Output is correct
63 Correct 280 ms 3580 KB Output is correct
64 Correct 273 ms 3576 KB Output is correct
65 Correct 264 ms 3516 KB Output is correct
66 Correct 281 ms 3560 KB Output is correct
67 Correct 430 ms 3576 KB Output is correct
68 Correct 405 ms 3564 KB Output is correct
69 Correct 398 ms 3576 KB Output is correct
70 Correct 379 ms 3576 KB Output is correct
71 Correct 382 ms 3596 KB Output is correct
72 Correct 378 ms 3704 KB Output is correct
73 Correct 398 ms 3576 KB Output is correct
74 Correct 410 ms 3704 KB Output is correct
75 Correct 334 ms 3576 KB Output is correct
76 Correct 346 ms 3704 KB Output is correct
77 Correct 351 ms 3576 KB Output is correct
78 Correct 326 ms 3576 KB Output is correct
79 Correct 243 ms 3576 KB Output is correct
80 Correct 387 ms 3564 KB Output is correct
81 Correct 359 ms 3596 KB Output is correct
82 Correct 343 ms 3564 KB Output is correct
83 Correct 328 ms 3448 KB Output is correct
84 Correct 499 ms 3576 KB Output is correct
85 Correct 535 ms 3576 KB Output is correct
86 Correct 484 ms 3576 KB Output is correct
87 Correct 511 ms 3592 KB Output is correct
88 Correct 539 ms 3496 KB Output is correct
89 Correct 563 ms 3576 KB Output is correct
90 Correct 558 ms 3600 KB Output is correct
91 Correct 574 ms 3576 KB Output is correct
92 Correct 330 ms 3576 KB Output is correct
93 Execution timed out 1066 ms 3568 KB Time limit exceeded
94 Halted 0 ms 0 KB -