제출 #1115085

#제출 시각아이디문제언어결과실행 시간메모리
1115085Icelast캥거루 (CEOI16_kangaroo)C++17
6 / 100
1 ms336 KiB
#include <iostream> #include <bits/stdc++.h> #define ll long long using namespace std; const ll maxn = 2*1e5+5, INF = 4e18+9, mod = 1e9+7; void solve(){ int n, cs, cf; cin >> n >> cs >> cf; if(cs > cf) swap(cs, cf); vector<vector<ll>> f(n+1, vector<ll>(n+1, 0)); f[0][0] = 1; for(int i = 1; i <= n; i++){ for(int j = 1; j <= n; j++){ if(i == cs){ f[i][j] += f[i-1][j]; f[i][j] += f[i-1][j-1]; f[i][j] += 0; } if(i == cf){ f[i][j] += f[i-1][j]; f[i][j] += f[i-1][j-1]; f[i][j] += 0; } if(i < cs){ f[i][j] += 0; f[i][j] += f[i-1][j-1]*j; if(j+1 <= n) f[i][j] += f[i-1][j+1]*j; } if(cs < i && i < cf){ f[i][j] += 0; f[i][j] += f[i-1][j-1]*(j-1); if(j+1 <= n) f[i][j] += f[i-1][j+1]*j; } if(cf < i){ f[i][j] += 0; f[i][j] += f[i-1][j-1]*(j-1); if(j+1 <= n) f[i][j] += f[i-1][j+1]*j; } f[i][j] %= mod; } } cout << f[n][1]; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...