제출 #43382

#제출 시각아이디문제언어결과실행 시간메모리
43382funcsr캥거루 (CEOI16_kangaroo)C++14
0 / 100
2 ms484 KiB
#include <cstdio> #include <iostream> #include <algorithm> #include <string> #include <cstring> #include <vector> #include <queue> #include <set> #include <map> #include <cmath> #include <iomanip> #include <cassert> #include <bitset> using namespace std; typedef pair<int, int> P; #define rep(i, n) for (int i=0; i<(n); i++) #define all(c) (c).begin(), (c).end() #define uniq(c) c.erase(unique(all(c)), (c).end()) #define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin()) #define _1 first #define _2 second #define pb push_back #define INF 1145141919 #define MOD 1000000007 inline void add(int &x, int v) { x += v; if (x >= MOD) x -= MOD; } int dp[201][201][201]; int solve(int N, int CS, int CF) { rep(i, N+1) rep(j, N+1) rep(k, N+1) dp[i][j][k] = 0; dp[0][CS][CF-(CS<CF)] = 1; rep(i, N-1) { int n = N-1-i; rep(j, N+1) { rep(k, N+1) { if (dp[i][j][k] == 0) continue; //cout<<"dp["<<i<<"]["<<j<<"]["<<k<<"]="<<dp[i][j][k]<<"\n"; if (i%2 == 0) { for (int x=j; x<n; x++) { if (i != N-1 && x == k) continue; add(dp[i+1][x][k-(x<=k)], dp[i][j][k]); } } else { for (int x=0; x<j; x++) { if (i != N-1 && x == k) continue; add(dp[i+1][x][k-(x<=k)], dp[i][j][k]); } } } } } int s = 0; rep(j, N+1) rep(k, N+1) add(s, dp[N-2][j][k]); return s; } signed main() { ios::sync_with_stdio(false); cin.tie(0); int N, CS, CF; cin >> N >> CS >> CF; CS--, CF--; int s = solve(N, CS, CF); CS = N-1-CS, CF = N-1-CF; add(s, solve(N, CS, CF)); cout << s << "\n"; 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...