# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
727085 |
2023-04-20T03:35:12 Z |
stasio6 |
Bowling (BOI15_bow) |
C++14 |
|
8 ms |
468 KB |
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back
#define FI first
#define ND second
#define maxeq(x, y) (x) = max((x), (y))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int maxFrameScore[11] = {0, 10, 30, 60, 90, 120, 150, 180, 210, 240, 300};
int score[20];
ll dp[15][500][3];
string game;
bool cmp(int i, char c1, char c2) {
return (game[2*(i-1)] == '?' || game[2*(i-1)] == c1) && (game[2*(i-1)+1] == '?' || game[2*(i-1)+1] == c2);
}
bool scorecmp(int i, int s) {
return score[i] == -1 || score[i] == s;
}
void fun() {
int n;
cin >> n;
cin >> game;
for (int i = 1; i <= n; i++) {
cin >> score[i];
}
for (int i = 0; i < 15; i++)
for (int s = 0; s < 500; s++)
for (int st = 0; st < 3; st++)
dp[i][s][st]= 0;
dp[0][0][0] = 1;
for (int i = 1; i <= n; i++) {
for (int s = 0; s <= maxFrameScore[i]; s++) {
// Strike
// if (s >= 10 + d + p && cmp(i, 'x', '-'))
// dp[i][s][p][d] += dp[i-1][s - 10 - p - d][10][p];
// TODO:
for (int r1 = 0; r1 < 10; r1++) {
for (int r2 = 0; r2 <= 10 - r1; r2++) {
int spare = 0;
if (r1 + r2 == 10) {
if (!cmp(i, '0' + r1, '/'))
continue;
spare = 1;
} else {
if (!cmp(i, '0' + r1, '0' + r2))
continue;
}
if (s >= r1 + r2) {
if (scorecmp(i-1, s-r1-r2))
dp[i][s][spare] += dp[i-1][s-r1-r2][0];
}
if (s >= r1 + r2 + r1) {
if (scorecmp(i-1, s-r1-r2))
dp[i][s][spare] += dp[i-1][s-r1-r2-r1][1];
}
if (s >= 2*(r1 + r2)) {
if (scorecmp(i-1, s-r1-r2))
dp[i][s][spare] += dp[i-1][s-2*(r1-r2)][2];
}
}
}
}
}
int ile = 0;
for (int s = 0; s <= 400; s++) {
ile += dp[n - 1][s][0];
}
cout << ile << "\n";
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) fun();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |