結果
問題 |
No.93 ペガサス
|
ユーザー |
![]() |
提出日時 | 2020-03-26 22:35:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 49 ms / 5,000 ms |
コード長 | 1,229 bytes |
コンパイル時間 | 988 ms |
コンパイル使用メモリ | 107,044 KB |
実行使用メモリ | 31,232 KB |
最終ジャッジ日時 | 2025-01-02 07:37:47 |
合計ジャッジ時間 | 2,330 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #include <utility> #include <functional> #include <time.h> #include <stack> #include <array> #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair<int, int> P; const ll MOD=1e9+7; ll dp[2][2][1010][1010]; int main() { int n; cin>>n; if(n==1) cout<<1<<endl; else if(n==2) cout<<2<<endl; if(n<=2) return 0; dp[0][0][2][0]=2; for(int i=2; i<n; i++){ for(int j=0; j<=i+1; j++){ for(int p=0; p<2; p++){ for(int q=0; q<2; q++){ int c=j, d=i+1, e=2; if(p){ (dp[q][1][i+1][j]+=dp[p][q][i][j])%=MOD; c--, d--, e--; } if(q){ (dp[0][0][i+1][j-1]+=dp[p][q][i][j])%=MOD; c--, d--; } (dp[q][1][i+1][j+1]+=dp[p][q][i][j]*e)%=MOD; (dp[q][0][i+1][j-1]+=dp[p][q][i][j]*c)%=MOD; (dp[q][0][i+1][j]+=dp[p][q][i][j]*(d-c-e))%=MOD; } } } } cout<<dp[0][0][n][0]<<endl; return 0; }