提出 #41154363
ソースコード 拡げる
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
#ifdef LOCAL
#define debug(...) fprintf(stderr,##__VA_ARGS__)
#else
#define debug(...) void(0)
#endif
typedef long long LL;
const int P=998244353;
LL mod(LL x){return (x%P+P)%P;}
void red(LL&x){x=mod(x);}
LL qpow(LL a,LL b,int p=P){LL r=1;for(a%=p;b;b>>=1,a=a*a%p) if(b&1) r=r*a%p; return r;}
template<int N,int P> struct C_prime{
LL fac[N+10],ifac[N+10];
C_prime(){
for(int i=fac[0]=ifac[0]=1;i<=N;i++) fac[i]=fac[i-1]*i%P;
ifac[N]=qpow(fac[N],P-2,P);
for(int i=N-1;i>=1;i--) ifac[i]=ifac[i+1]*(i+1)%P;
}
LL operator()(int n,int m){return n>=m?fac[n]*ifac[n-m]%P*ifac[m]%P:0;}
};
int n,m,k,X,buc[1<<11],sum[1<<11];
C_prime<1<<20,P> Z;
LL f[1<<12][1<<11],g[1<<12][1<<11];
LL dp(){
f[0][0]=0,g[0][0]=1;
for(int j=1;j<=m;j++){
auto calc=[&](int l,int r)->int{
auto len=[](int l,int r)->int{return max(r-l+1,0);};
return len(l,r)-len(max(l,X),min(r,X+k-1));
};
for(int i=sum[j-1];i<=n+k;i++){
for(int x=buc[j];i+x<=n+k;x++){
LL z=Z(k-(i-sum[j-1]),x-buc[j]);
red(g[i+x][j]+=g[i][j-1]*z);
red(f[i+x][j]+=(f[i][j-1]+g[i][j-1]*calc(i+1,i+x)*j%P)*z);
}
}
#ifdef LOCAL
for(int i=sum[j];i<=n+k;i++) debug("i=%d,j=%d,f=%lld,g=%lld\n",i,j,f[i][j],g[i][j]);
#endif
}
return f[n+k][m];
}
int main(){
// #ifdef LOCAL
// freopen("input.in","r",stdin);
// #endif
scanf("%d%d%d%d",&n,&m,&k,&X);
for(int i=1,x;i<=n;i++) scanf("%d",&x),buc[x]++;
for(int i=1;i<=m;i++) sum[i]=sum[i-1]+buc[i];
printf("%lld\n",dp());
return 0;
}
提出情報
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:53:7: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
53 | scanf("%d%d%d%d",&n,&m,&k,&X);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
./Main.cpp:54:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
54 | for(int i=1,x;i<=n;i++) scanf("%d",&x),buc[x]++;
| ~~~~~^~~~~~~~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
0 / 700 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
example_00.txt, example_01.txt |
| All |
example_00.txt, example_01.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt, test_44.txt, test_45.txt, test_46.txt, test_47.txt, test_48.txt, test_49.txt, test_50.txt, test_51.txt, test_52.txt, test_53.txt, test_54.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| example_00.txt |
AC |
27 ms |
18088 KiB |
| example_01.txt |
AC |
22 ms |
18132 KiB |
| test_00.txt |
TLE |
2207 ms |
29600 KiB |
| test_01.txt |
TLE |
2207 ms |
30436 KiB |
| test_02.txt |
TLE |
2207 ms |
30560 KiB |
| test_03.txt |
TLE |
2207 ms |
37276 KiB |
| test_04.txt |
TLE |
2207 ms |
32452 KiB |
| test_05.txt |
AC |
98 ms |
20900 KiB |
| test_06.txt |
TLE |
2207 ms |
43372 KiB |
| test_07.txt |
TLE |
2207 ms |
40128 KiB |
| test_08.txt |
TLE |
2207 ms |
31376 KiB |
| test_09.txt |
TLE |
2207 ms |
33924 KiB |
| test_10.txt |
TLE |
2206 ms |
27420 KiB |
| test_11.txt |
TLE |
2207 ms |
33340 KiB |
| test_12.txt |
TLE |
2207 ms |
33560 KiB |
| test_13.txt |
TLE |
2207 ms |
33616 KiB |
| test_14.txt |
TLE |
2207 ms |
39648 KiB |
| test_15.txt |
TLE |
2207 ms |
34020 KiB |
| test_16.txt |
TLE |
2207 ms |
31028 KiB |
| test_17.txt |
AC |
1336 ms |
25908 KiB |
| test_18.txt |
TLE |
2207 ms |
39724 KiB |
| test_19.txt |
TLE |
2207 ms |
34736 KiB |
| test_20.txt |
TLE |
2207 ms |
38160 KiB |
| test_21.txt |
TLE |
2207 ms |
37852 KiB |
| test_22.txt |
TLE |
2207 ms |
28364 KiB |
| test_23.txt |
TLE |
2207 ms |
35184 KiB |
| test_24.txt |
TLE |
2207 ms |
31252 KiB |
| test_25.txt |
TLE |
2208 ms |
49928 KiB |
| test_26.txt |
TLE |
2208 ms |
49868 KiB |
| test_27.txt |
TLE |
2208 ms |
49876 KiB |
| test_28.txt |
TLE |
2208 ms |
49940 KiB |
| test_29.txt |
TLE |
2208 ms |
49872 KiB |
| test_30.txt |
TLE |
2208 ms |
49920 KiB |
| test_31.txt |
TLE |
2208 ms |
49948 KiB |
| test_32.txt |
TLE |
2208 ms |
49868 KiB |
| test_33.txt |
TLE |
2208 ms |
49924 KiB |
| test_34.txt |
TLE |
2208 ms |
49876 KiB |
| test_35.txt |
TLE |
2207 ms |
33436 KiB |
| test_36.txt |
TLE |
2207 ms |
33420 KiB |
| test_37.txt |
TLE |
2207 ms |
33228 KiB |
| test_38.txt |
TLE |
2207 ms |
33220 KiB |
| test_39.txt |
TLE |
2207 ms |
33792 KiB |
| test_40.txt |
TLE |
2207 ms |
33560 KiB |
| test_41.txt |
TLE |
2207 ms |
33916 KiB |
| test_42.txt |
TLE |
2207 ms |
33128 KiB |
| test_43.txt |
TLE |
2207 ms |
33076 KiB |
| test_44.txt |
TLE |
2207 ms |
33756 KiB |
| test_45.txt |
TLE |
2208 ms |
48848 KiB |
| test_46.txt |
TLE |
2208 ms |
48588 KiB |
| test_47.txt |
TLE |
2208 ms |
49248 KiB |
| test_48.txt |
TLE |
2208 ms |
49240 KiB |
| test_49.txt |
TLE |
2208 ms |
48660 KiB |
| test_50.txt |
TLE |
2208 ms |
49352 KiB |
| test_51.txt |
TLE |
2208 ms |
49152 KiB |
| test_52.txt |
TLE |
2208 ms |
49316 KiB |
| test_53.txt |
TLE |
2208 ms |
48956 KiB |
| test_54.txt |
TLE |
2208 ms |
48968 KiB |