| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 53808 | ruhanhabib39 | Bowling (BOI15_bow) | C++17 | 3 ms | 1000 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n;
char match[2 * 10 + 10];
int sum[2 * 10 + 10];
long long dp[15][10 * 30 + 10];
long long calc(int i, int s) {
if(dp[i][s] != -1) return dp[i][s];
dp[i][s] = 0;
if(i > 0 && sum[i-1] != -1 && s != sum[i-1]) return 0;
if(i == n) return dp[i][s] = 1;
if(match[2*i] != '?' && match[2*i+1] != '?') {
assert(isdigit(match[2*i]) && isdigit(match[2*i+1]));
return dp[i][s] = calc(i+1, s + int(match[2*i] - '0') + int(match[2*i+1] - '0'));
}
bool both = match[2*i] == '?' && match[2*i+1] == '?';
int x = 0;
if(match[2*i] != '?') x = int(match[2*i] - '0');
else if(match[2*i+1] != '?') x = int(match[2*i+1] - '0');
for(; x < 10; x++) {
if(both) dp[i][s] += calc(i+1, s+x) * (x + 1);
else dp[i][s] += calc(i+1, s+x);
}
return dp[i][s];
}
int main() {
int q; scanf("%d", &q);
for(int t = 0; t < q; t++) {
scanf("%d%s", &n, match);
for(int i = 0; i < n; i++) {
scanf("%d", &sum[i]);
}
memset(dp, -1, sizeof dp);
if(count(match, match + 2*n + 1, 'x') || count(match, match + 2*n + 1, '/')) printf("0\n");
else printf("%lld\n", calc(0, 0));
}
}
컴파일 시 표준 에러 (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... | ||||
