#include<bits/stdc++.h>
using namespace std;
#define int long long
const int K=300;
void solve(){
int n;cin>>n;
string s;cin>>s;
vector<int> v(n+1);
for(int i=1;i<=n;i++){
cin>>v[i];
}
vector<int> dp(301),dp1(301);
dp[0]=1;
for(int i=1;i<=n;i++){
int l1=0,r1=9;
int l2=0,r2=9;
if(s[i*2-2]>='0'&&s[i*2-2]<='9'){
l1=s[i*2-2]-'0';
r1=s[i*2-2]-'0';
}
if(s[i*2-1]>='0'&&s[i*2-1]<='9'){
l2=s[i*2-1]-'0';
r2=s[i*2-1]-'0';
}
int l3=0,r3=300;
if(v[i]!=-1){
l3=v[i],r3=v[i];
}
for(int j=l3;j<=r3;j++){
for(int j1=l1;j1<=r1;j1++){
for(int j2=l2;j2<=r2;j2++){
if(j1+j2>9){
continue;
}
if(j>=j1+j2){
dp1[j]+=dp[j-j1-j2];
}
}
}
}
swap(dp,dp1);
dp1.assign(K+1,0);
}
int ans=0;
for(int i=0;i<=K;i++){
ans+=dp[i];
}
cout<<ans<<endl;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;cin>>t;
while(t--){
solve();
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
328 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
320 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
212 KB |
Output is correct |
15 |
Correct |
2 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
2 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |