답안 #127775

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
127775 2019-07-10T05:57:26 Z tmwilliamlin168 Bowling (BOI15_bow) C++14
100 / 100
781 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(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)+"-"});
	//cout << vs.size() << " " << vf.size() << endl;
	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)
                 ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 3576 KB Output is correct
2 Correct 30 ms 3580 KB Output is correct
3 Correct 21 ms 3448 KB Output is correct
4 Correct 33 ms 3576 KB Output is correct
5 Correct 29 ms 3448 KB Output is correct
6 Correct 25 ms 3576 KB Output is correct
7 Correct 27 ms 3576 KB Output is correct
8 Correct 31 ms 3448 KB Output is correct
9 Correct 28 ms 3576 KB Output is correct
10 Correct 27 ms 3576 KB Output is correct
11 Correct 34 ms 3576 KB Output is correct
12 Correct 112 ms 3560 KB Output is correct
13 Correct 25 ms 3448 KB Output is correct
14 Correct 108 ms 3448 KB Output is correct
15 Correct 30 ms 3448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 66 ms 3448 KB Output is correct
2 Correct 106 ms 3576 KB Output is correct
3 Correct 95 ms 3448 KB Output is correct
4 Correct 84 ms 3576 KB Output is correct
5 Correct 118 ms 3576 KB Output is correct
6 Correct 91 ms 3576 KB Output is correct
7 Correct 105 ms 3452 KB Output is correct
8 Correct 92 ms 3576 KB Output is correct
9 Correct 91 ms 3704 KB Output is correct
10 Correct 226 ms 3576 KB Output is correct
11 Correct 243 ms 3576 KB Output is correct
12 Correct 233 ms 3576 KB Output is correct
13 Correct 253 ms 3576 KB Output is correct
14 Correct 246 ms 3592 KB Output is correct
15 Correct 246 ms 3576 KB Output is correct
16 Correct 256 ms 3704 KB Output is correct
17 Correct 251 ms 3576 KB Output is correct
18 Correct 206 ms 3576 KB Output is correct
19 Correct 194 ms 3676 KB Output is correct
20 Correct 246 ms 3676 KB Output is correct
21 Correct 228 ms 3576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 3576 KB Output is correct
2 Correct 83 ms 3704 KB Output is correct
3 Correct 85 ms 3448 KB Output is correct
4 Correct 64 ms 3576 KB Output is correct
5 Correct 60 ms 3580 KB Output is correct
6 Correct 86 ms 3448 KB Output is correct
7 Correct 115 ms 3556 KB Output is correct
8 Correct 90 ms 3556 KB Output is correct
9 Correct 113 ms 3576 KB Output is correct
10 Correct 274 ms 3576 KB Output is correct
11 Correct 292 ms 3576 KB Output is correct
12 Correct 274 ms 3676 KB Output is correct
13 Correct 264 ms 3576 KB Output is correct
14 Correct 209 ms 3704 KB Output is correct
15 Correct 210 ms 3592 KB Output is correct
16 Correct 232 ms 3576 KB Output is correct
17 Correct 209 ms 3604 KB Output is correct
18 Correct 42 ms 3576 KB Output is correct
19 Correct 42 ms 3576 KB Output is correct
20 Correct 44 ms 3676 KB Output is correct
21 Correct 31 ms 3576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 95 ms 3576 KB Output is correct
2 Correct 68 ms 3576 KB Output is correct
3 Correct 85 ms 3448 KB Output is correct
4 Correct 84 ms 3580 KB Output is correct
5 Correct 64 ms 3576 KB Output is correct
6 Correct 60 ms 3576 KB Output is correct
7 Correct 65 ms 3576 KB Output is correct
8 Correct 61 ms 3576 KB Output is correct
9 Correct 68 ms 3576 KB Output is correct
10 Correct 170 ms 3680 KB Output is correct
11 Correct 165 ms 3576 KB Output is correct
12 Correct 159 ms 3552 KB Output is correct
13 Correct 148 ms 3576 KB Output is correct
14 Correct 71 ms 3448 KB Output is correct
15 Correct 71 ms 3576 KB Output is correct
16 Correct 85 ms 3548 KB Output is correct
17 Correct 87 ms 3576 KB Output is correct
18 Correct 31 ms 3576 KB Output is correct
19 Correct 33 ms 3576 KB Output is correct
20 Correct 29 ms 3576 KB Output is correct
21 Correct 25 ms 3576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 49 ms 3576 KB Output is correct
2 Correct 30 ms 3580 KB Output is correct
3 Correct 21 ms 3448 KB Output is correct
4 Correct 33 ms 3576 KB Output is correct
5 Correct 29 ms 3448 KB Output is correct
6 Correct 25 ms 3576 KB Output is correct
7 Correct 27 ms 3576 KB Output is correct
8 Correct 31 ms 3448 KB Output is correct
9 Correct 28 ms 3576 KB Output is correct
10 Correct 27 ms 3576 KB Output is correct
11 Correct 34 ms 3576 KB Output is correct
12 Correct 112 ms 3560 KB Output is correct
13 Correct 25 ms 3448 KB Output is correct
14 Correct 108 ms 3448 KB Output is correct
15 Correct 30 ms 3448 KB Output is correct
16 Correct 66 ms 3448 KB Output is correct
17 Correct 106 ms 3576 KB Output is correct
18 Correct 95 ms 3448 KB Output is correct
19 Correct 84 ms 3576 KB Output is correct
20 Correct 118 ms 3576 KB Output is correct
21 Correct 91 ms 3576 KB Output is correct
22 Correct 105 ms 3452 KB Output is correct
23 Correct 92 ms 3576 KB Output is correct
24 Correct 91 ms 3704 KB Output is correct
25 Correct 226 ms 3576 KB Output is correct
26 Correct 243 ms 3576 KB Output is correct
27 Correct 233 ms 3576 KB Output is correct
28 Correct 253 ms 3576 KB Output is correct
29 Correct 246 ms 3592 KB Output is correct
30 Correct 246 ms 3576 KB Output is correct
31 Correct 256 ms 3704 KB Output is correct
32 Correct 251 ms 3576 KB Output is correct
33 Correct 206 ms 3576 KB Output is correct
34 Correct 194 ms 3676 KB Output is correct
35 Correct 246 ms 3676 KB Output is correct
36 Correct 228 ms 3576 KB Output is correct
37 Correct 75 ms 3576 KB Output is correct
38 Correct 83 ms 3704 KB Output is correct
39 Correct 85 ms 3448 KB Output is correct
40 Correct 64 ms 3576 KB Output is correct
41 Correct 60 ms 3580 KB Output is correct
42 Correct 86 ms 3448 KB Output is correct
43 Correct 115 ms 3556 KB Output is correct
44 Correct 90 ms 3556 KB Output is correct
45 Correct 113 ms 3576 KB Output is correct
46 Correct 274 ms 3576 KB Output is correct
47 Correct 292 ms 3576 KB Output is correct
48 Correct 274 ms 3676 KB Output is correct
49 Correct 264 ms 3576 KB Output is correct
50 Correct 209 ms 3704 KB Output is correct
51 Correct 210 ms 3592 KB Output is correct
52 Correct 232 ms 3576 KB Output is correct
53 Correct 209 ms 3604 KB Output is correct
54 Correct 42 ms 3576 KB Output is correct
55 Correct 42 ms 3576 KB Output is correct
56 Correct 44 ms 3676 KB Output is correct
57 Correct 31 ms 3576 KB Output is correct
58 Correct 95 ms 3576 KB Output is correct
59 Correct 68 ms 3576 KB Output is correct
60 Correct 85 ms 3448 KB Output is correct
61 Correct 84 ms 3580 KB Output is correct
62 Correct 64 ms 3576 KB Output is correct
63 Correct 60 ms 3576 KB Output is correct
64 Correct 65 ms 3576 KB Output is correct
65 Correct 61 ms 3576 KB Output is correct
66 Correct 68 ms 3576 KB Output is correct
67 Correct 170 ms 3680 KB Output is correct
68 Correct 165 ms 3576 KB Output is correct
69 Correct 159 ms 3552 KB Output is correct
70 Correct 148 ms 3576 KB Output is correct
71 Correct 71 ms 3448 KB Output is correct
72 Correct 71 ms 3576 KB Output is correct
73 Correct 85 ms 3548 KB Output is correct
74 Correct 87 ms 3576 KB Output is correct
75 Correct 31 ms 3576 KB Output is correct
76 Correct 33 ms 3576 KB Output is correct
77 Correct 29 ms 3576 KB Output is correct
78 Correct 25 ms 3576 KB Output is correct
79 Correct 118 ms 3576 KB Output is correct
80 Correct 147 ms 3560 KB Output is correct
81 Correct 130 ms 3704 KB Output is correct
82 Correct 100 ms 3576 KB Output is correct
83 Correct 102 ms 3448 KB Output is correct
84 Correct 173 ms 3576 KB Output is correct
85 Correct 217 ms 3552 KB Output is correct
86 Correct 171 ms 3704 KB Output is correct
87 Correct 195 ms 3576 KB Output is correct
88 Correct 209 ms 3576 KB Output is correct
89 Correct 237 ms 3560 KB Output is correct
90 Correct 238 ms 3324 KB Output is correct
91 Correct 232 ms 3576 KB Output is correct
92 Correct 19 ms 3448 KB Output is correct
93 Correct 770 ms 3576 KB Output is correct
94 Correct 749 ms 3576 KB Output is correct
95 Correct 754 ms 3648 KB Output is correct
96 Correct 749 ms 3576 KB Output is correct
97 Correct 747 ms 3580 KB Output is correct
98 Correct 754 ms 3704 KB Output is correct
99 Correct 754 ms 3704 KB Output is correct
100 Correct 781 ms 3560 KB Output is correct