結果
問題 |
No.93 ペガサス
|
ユーザー |
![]() |
提出日時 | 2025-09-05 22:18:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 21 ms / 5,000 ms |
コード長 | 1,441 bytes |
コンパイル時間 | 1,394 ms |
コンパイル使用メモリ | 161,640 KB |
実行使用メモリ | 34,396 KB |
最終ジャッジ日時 | 2025-09-05 22:18:26 |
合計ジャッジ時間 | 2,404 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#include <bits/stdc++.h> #define lint __int128 #define int long long #define fi first #define se second #define Il inline #define vec vector #define pb push_back #define IT ::iterator #define p_q priority_queue using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef double db; const int N=1e3,mod=1e9+7; const db eps=1e-9,pi=acos(-1.0); mt19937 rnd(time(0)); Il int rint(int l,int r){return rnd()%(r-l+1)+l;} int n,f[N+5][N+5][2][2]; signed main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n,f[1][0][0][0]=1,f[2][0][0][0]=2; for(int i=3;i<=n;i++){ for(int j=0;j<i;j++){ f[i][j][0][0]=((i-j-2)*f[i-1][j][0][0]%mod+(i-j-1)*f[i-1][j][0][1]%mod+(j+1)*f[i-1][j+1][0][0]%mod+j*f[i-1][j+1][0][1]%mod+f[i-1][j+1][1][0]+f[i-1][j+1][1][1])%mod; f[i][j][0][1]=((i-j-2)*f[i-1][j][1][0]%mod+(i-j-1)*f[i-1][j][1][1]%mod+j*f[i-1][j+1][1][0]%mod+(j?(j-1)*f[i-1][j+1][1][1]%mod:0))%mod; f[i][j][1][0]=(f[i-1][j][0][1]+(j?(f[i-1][j-1][0][0]<<1ll)%mod+f[i-1][j-1][0][1]:0)%mod)%mod; f[i][j][1][1]=(f[i-1][j][1][1]+(j?(f[i-1][j-1][1][0]<<1ll)%mod+f[i-1][j-1][1][1]:0)%mod)%mod; // for(int a=0;a<2;a++)for(int b=0;b<2;b++)cout<<i<<' '<<j<<' '<<a<<' '<<b<<' '<<f[i][j][a][b]<<'\n'; } } cout<<f[n][0][0][0]; return 0; } /* ????? ??? ? ?????| ?_? _| ? ????`? _x ? ?? ? /??? ? | ??? /? ??? ? ???|?? |?|?| ?| (???_?_)_) ???? */