(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

제출 #24974

#제출 시각아이디문제언어결과실행 시간메모리
24974kajebiii캥거루 (CEOI16_kangaroo)C++14
100 / 100
46 ms17800 KiB
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) #define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++) #define SZ(v) ((int)(v).size()) #define ALL(v) (v).begin(),(v).end() #define one first #define two second typedef long long ll; typedef pair<int, int> pi; const int INF = 0x3f2f1f0f; const ll LINF = 1ll * INF * INF; const int MOD = 1e9 + 7, MAX_N = 2e3 + 10; int N, S, E, Dy[MAX_N][MAX_N]; void add(int &a, int b) { if((a+=b) >= MOD) a -= MOD; if(a < 0) a += MOD; } int main() { cin >> N >> S >> E; Dy[0][0] = 1; int cnt = 0; for(int i=1; i<=N; i++) { if(i == S || i == E) { for(int j=0; j<=N; j++) { add(Dy[i][j], Dy[i-1][j]); add(Dy[i][j], Dy[i-1][j-1]); } cnt++; } else { for(int j=0; j<=N; j++) { if(j) add(Dy[i][j], 1ll * Dy[i-1][j-1] * (j - cnt) % MOD); add(Dy[i][j], 1ll * Dy[i-1][j+1] * j % MOD); } } } printf("%d\n", Dy[N][1]); 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...