제출 #575716

#제출 시각아이디문제언어결과실행 시간메모리
575716hoainiem캥거루 (CEOI16_kangaroo)C++14
100 / 100
38 ms16244 KiB
#include <bits/stdc++.h> //#pragma GCC target("popcnt") #define fi first #define se second #define lc id<<1 #define rc id<<1^1 #define val f[i][j] const int mod = 1e9 + 7; double begintime, endtime; using namespace std; inline void CALC_TIME() { endtime = clock(); cout << "\nexecution time : " << (endtime - begintime + 1) / 1000 << " s"; } void add(int &x, int y) { x += y; if (x >= mod) x -= mod; } int mul(int x, int y) { return 1LL * x * y % mod; } typedef pair<int, int> pii; int n, cs, cf; int f[2008][2008]; int dq(int i, int j) { if (val != -1) return val; if (i == n) return val = (j == 1); int res = 0; if (i + 1 == cs || i + 1 == cf) { add(res, dq(i + 1, j)); add(res, dq(i + 1, j + 1)); return val = res; } if (j > 1) add(res, mul(j - 1, dq(i + 1, j - 1))); add(res, mul(j + 1 - (i + 1 > cs) - (i + 1 > cf), dq(i + 1, j + 1))); return val = res; } int main() { begintime = clock(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); memset(f, -1, sizeof(f)); cin >> n >> cs >> cf; cout << dq(0, 0); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...