結果
| 問題 |
No.93 ペガサス
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-09-06 10:06:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 5,000 ms |
| コード長 | 968 bytes |
| コンパイル時間 | 1,661 ms |
| コンパイル使用メモリ | 161,936 KB |
| 実行使用メモリ | 22,912 KB |
| 最終ジャッジ日時 | 2025-09-06 10:06:14 |
| 合計ジャッジ時間 | 2,861 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int kmaxn=1000+10,mod=1e9+7;
int n,dp[kmaxn][kmaxn][2][2];//-1?-3????-2
signed main(){
// freopen("hero.in","r",stdin);
// freopen("hero.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n;
if(n<=2){
cout<<n<<"\n";
return 0;
}
dp[2][0][0][0]=2;
for(int i=3;i<=n;i++){
for(int j=0;j<i;j++){
for(int c=0;c<2;c++){
for(int l=0;l<2&&c+l<=j;l++){
if(l)(dp[i][j-1][0][0]+=dp[i-1][j][c][l])%=mod;
if(c)(dp[i][j][l][1]+=dp[i-1][j][c][l])%=mod;
(dp[i][j+1][l][1]+=dp[i-1][j][c][l]*(2-c))%=mod;
(dp[i][j][l][0]+=dp[i-1][j][c][l]*(i-j-2+c))%=mod;
(dp[i][j-1][l][0]+=dp[i-1][j][c][l]*(j-l-c))%=mod;
}
}
}
}
cout<<dp[n][0][0][0]<<"\n";
return 0;
}
vjudge1