이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pii pair<int, int>
#define ll long long
#define ld long double
#define L 0
#define R 1
const ll mod = 1000000007;
using namespace std;
int memo[201][201][201][2], n, cs, cf;
int dp(int size, int curr, int end, int orient) {
if (curr > size / 2 || curr == size / 2 && end > size / 2)
curr = size - curr + 1, end = size - end + 1, orient = 1 - orient;
if (memo[size][curr][end][orient] != -1)
return memo[size][curr][end][orient];
if (size == 1 && curr == 1 && end == 1)
return 1;
if (size != 1 && curr == end)
return 0;
int out = 0;
if (orient == L) {
for (int i = 1; i < curr; i++) {
if (curr < end)
out += dp(size - 1, i, end - 1, R), out %= mod;
else
out += dp(size - 1, i, end, R), out %= mod;
}
}
else {
for (int i = curr + 1; i <= size; i++) {
if (curr < end)
out += dp(size - 1, i - 1, end - 1, L), out %= mod;
else
out += dp(size - 1, i - 1, end, L), out %= mod;
}
}
return memo[size][curr][end][orient] = out;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
memset(memo, -1, sizeof(memo));
//freopen("kangaroo.in", "r", stdin);
//freopen("kangaroo.out", "w", stdout);
cin >> n >> cs >> cf;
cout << (dp(n, cs, cf, L) + dp(n, cs, cf, R)) % mod << "\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
kangaroo.cpp: In function 'int dp(int, int, int, int)':
kangaroo.cpp:16:45: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
16 | if (curr > size / 2 || curr == size / 2 && end > size / 2)
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
# | 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... |