#include <bits/stdc++.h>
#define int long long
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;
int score[20];
int dp[15][500][12][12];
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);
}
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 p = 0; p <= 10; p++)
for (int d = 0; d <= 10; d++)
dp[i][s][p][d] = 0;
for (int p = 0; p <= 10; p++) {
for (int d = 0; d <= 10; d++) {
dp[0][0][p][d] = 1;
}
}
for (int i = 1; i < n; i++) {
for (int s = 0; s <= 400; s++) {
if (score[i] != -1 && score[i] != s)
continue;
for (int p = 0; p <= 10; p++) {
for (int d = 0; d <= 10; d++) {
// Strike
if (s >= 10 + d + p && cmp(i, 'x', '-'))
dp[i][s][p][d] += dp[i-1][s - 10 - p - d][10][p];
for (int r1 = 0; r1 < 10; r1++) {
for (int r2 = 0; r2 <= 10 - r1; r2++) {
if (r1+r2 == 10) {
if (!cmp(i, '0'+r1, '/'))
continue;
if (s >= r1 + r2 + p)
dp[i][s][p][d] += dp[i-1][s - r1 - r2 - p][r1][r2];
} else {
if (!cmp(i, '0'+r1, '0'+r2))
continue;
if (s >= r1 + r2)
dp[i][s][p][d] += dp[i-1][s - r1 - r2][r1][r2];
}
}
}
}
}
}
}
int ile = 0;
for (int s = 0; s <= 400; s++) {
ile += dp[n - 1][s][0][0];
}
cout << ile << "\n";
}
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) fun();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
420 ms |
8760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
497 ms |
8752 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
228 ms |
8756 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
641 ms |
8768 KB |
Output is correct |
2 |
Correct |
554 ms |
8760 KB |
Output is correct |
3 |
Correct |
679 ms |
8764 KB |
Output is correct |
4 |
Correct |
616 ms |
8760 KB |
Output is correct |
5 |
Correct |
582 ms |
8756 KB |
Output is correct |
6 |
Correct |
493 ms |
8760 KB |
Output is correct |
7 |
Correct |
427 ms |
8760 KB |
Output is correct |
8 |
Correct |
480 ms |
8764 KB |
Output is correct |
9 |
Correct |
481 ms |
8772 KB |
Output is correct |
10 |
Execution timed out |
1067 ms |
8660 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
420 ms |
8760 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |