Submission #5895028
Source Code Expand
#include "bits/stdc++.h" using namespace std; int N,M,K,L,R,H,W; //const long long int MOD=1000000007; const long long int MOD=998244353; long long int power(long long int x, long long int n, long long int M) { long long int ret = 1; long long int by = x; while (n) { if (n & 1) { ret *= by; ret %= M; } by *= by; by %= M; n >>= 1; } return ret; } int main(){ cin>>N>>M; vector<vector<long long int>>dp(N+1,vector<long long int>(2*N+1)); dp[0][0]=1; for(int i=0;i<N;i++){ for(int j=i;j<=i*2;j++){ dp[i+1][j+1]+=dp[i][j]; dp[i+1][j+1]%=MOD; dp[i+1][j+2]+=dp[i][j]; dp[i+1][j+2]%=MOD; } } vector<long long int>num(N+1); for(int i=0;i<=N;i++){ for(int j=0;j<M;j++){ num[i]+=dp[i][j]; num[i]%=MOD; } } if(M&1){ for(int i=M+1;i<=2*N;i+=2){ num[i/2]++; } } //cout<<"hoge"<<endl; vector<long long int>by(N+1,1); vector<long long int>rev(N+1,1); for(int i=2;i<=N;i++){ by[i]=by[i-1]*i; by[i]%=MOD; rev[i]=power(by[i],MOD-2,MOD); } for(int i=0;i<=N;i++){ // cout<<i<<" "<<num[i]<<endl; } for(int i=2;i<M-1;i+=2){ if(M-1-i<0)break; for(int j=1;j<=N;j++){ if(j+i>N)break; num[j+i]+=dp[j][M-1-i]; num[j+i]%=MOD; } } long long int ans=0; for(int i=0;i<=N;i++){ // cout<<i<<" "<<num[i]<<endl; long long int add=by[N]; add*=rev[i]; add%=MOD; add*=rev[N-i]; add%=MOD; add*=num[i]; add%=MOD; ans+=add; ans%=MOD; } cout<<ans<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Banned X |
User | olphe |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1534 Byte |
Status | WA |
Exec Time | 183 ms |
Memory | 141184 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 800 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt, s4.txt, s5.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, s1.txt, s2.txt, s3.txt, s4.txt, s5.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 183 ms | 141184 KB |
02.txt | WA | 183 ms | 141184 KB |
03.txt | AC | 97 ms | 80256 KB |
04.txt | WA | 126 ms | 108416 KB |
05.txt | AC | 132 ms | 123776 KB |
06.txt | WA | 133 ms | 124928 KB |
07.txt | WA | 108 ms | 111232 KB |
08.txt | WA | 162 ms | 130304 KB |
09.txt | WA | 87 ms | 140160 KB |
10.txt | AC | 78 ms | 79104 KB |
11.txt | AC | 1 ms | 256 KB |
12.txt | AC | 1 ms | 256 KB |
13.txt | AC | 1 ms | 256 KB |
14.txt | AC | 1 ms | 256 KB |
15.txt | AC | 1 ms | 256 KB |
16.txt | AC | 81 ms | 141184 KB |
17.txt | AC | 180 ms | 139136 KB |
18.txt | WA | 172 ms | 132608 KB |
19.txt | AC | 80 ms | 141184 KB |
20.txt | WA | 9 ms | 12672 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 1 ms | 256 KB |
s4.txt | WA | 1 ms | 256 KB |
s5.txt | WA | 2 ms | 1792 KB |