이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
#define vt vector
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ROF(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define F0R(i, b) FOR (i, 0, b)
#define endl '\n'
#define debug(x) do{auto _x = x; cerr << #x << " = " << _x << endl;} while(0)
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
void add(ll& a, ll b) {
a = (a + (b % MOD)) % MOD;
}
main() {
cin.tie(0)->sync_with_stdio(0);
int n, st, en; cin >> n >> st >> en;
vt dp(n + 1, vt<ll>(n + 2));
dp[1][1] = 1;
FOR (i, 2, n + 1) {
FOR (j, 1, n + 1) {
if (i == st || i == en) { // place either as a new component, or glue to some previous one
add(dp[i][j], dp[i - 1][j - 1] + dp[i - 1][j]);
} else { // place either as a new component, or glue together two previous ones
add(dp[i][j], dp[i - 1][j - 1] * (j - (i > st) - (i > en)) + dp[i - 1][j + 1] * j);
}
}
}
cout << dp[n][1] << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
kangaroo.cpp:25:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
25 | main() {
| ^~~~
# | 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... |