# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
113198 | davitmarg | Bowling (BOI15_bow) | C++17 | 2 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <ctype.h>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin (),v.end()
using namespace std;
int t, n,a[15],sum[15];
LL ans;
char tmp;
int main()
{
cin >> t;
while (t--)
{
scanf("%d", &n);
ans = 1;
n *= 2;
for (int i = 1; i <= n; i++)
{
scanf(" %c",&tmp);
a[i] = tmp - '0';
if (tmp == '?')
a[i] = -1;
}
scanf(" %c", &tmp);
for (int i = 2; i <= n; i += 2)
scanf("%d", sum + i);
for (int i = 2; i <= n; i += 2)
{
if (sum[i] >= 10)
ans = 0;
if (sum[i] == -1 )
{
if (min(a[i - 1], a[i]) != -1)
{
sum[i] = a[i - 1] + a[i];
continue;
}
else if(a[i-1]==a[i])
ans *= (LL)(10+9+8+7+6+5+4+3+2+1);
else
{
LL x = max(a[i - 1], a[i]);
ans *= 10ll - x;
}
}
else
{
if (min(a[i - 1], a[i]) != -1)
ans *= (a[i - 1] + a[i] == sum[i]);
else if (a[i - 1] == a[i])
ans *= (sum[i]+1);
else
{
LL x = max(a[i - 1], a[i]);
ans *= (x <= sum[i]);
}
}
}
printf("%lld\n",ans);
}
return 0;
}
/*
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |