# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
209794 | FutymyClone | Zapina (COCI20_zapina) | C++14 | 164 ms | 1808 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 355;
const int mod = 1e9 + 7;
int n, f[N][N], g[N][N], C[N][N];
void add (int &x, int y) {
x += y;
if (x >= mod) x -= mod;
}
int main(){
scanf("%d", &n);
for (int i = 0; i <= n; i++) {
for (int j = 0; j <= i; j++) {
if (!i || !j || i == j) C[i][j] = 1;
else C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
}
}
f[0][0] = 1;
for (int i = 0; i < n; i++) {
for (int j = 0; j <= n; j++) {
for (int k = 0; j + k <= n; k++) {
add(f[i + 1][j + k], 1LL * f[i][j] * C[n - j][k] % mod);
}
}
}
g[0][0] = 1;
for (int i = 0; i < n; i++) {
for (int j = 0; j <= n; j++) {
for (int k = 0; j + k <= n; k++) {
if (k == i + 1) continue;
add(g[i + 1][j + k], 1LL * g[i][j] * C[n - j][k] % mod);
}
}
}
int ans = f[n][n] - g[n][n];
if (ans < 0) ans += mod;
printf("%d", ans);
return 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... |