QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#103203 | #4794. Salaj | lyx123886a123886 | WA | 48ms | 3552kb | C++14 | 1.3kb | 2023-05-04 18:53:26 | 2023-05-04 18:53:30 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int read()
{
char ch=getchar();int res=0,fl=1;
while(ch<'0'||ch>'9'){if(ch=='-') fl=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){res=res*10+ch-'0';ch=getchar();}
return res*fl;
}
const int N=55;
int dp[N][N],s[N][N];//s:后缀和
void solve()
{
memset(dp,0,sizeof(dp));
memset(s,0,sizeof(s));
int n=read(),m=read(),mod=read();
dp[0][1]=1;
for(int k=1;k<=n;++k)
for(int j=n-1;j>=0;--j)
s[j][k]=(s[j+1][k]+dp[j][k])%mod;
for(int i=1;i<=m;++i)
{
for(int j=n-1;j>=0;--j)
for(int k=n;k>=j+1;--k)
{
if(i<=j*(j-1)/2+1+(k-j)*(k-1)/*no /2!!*/+(n-k)*(n-k-1)/2||1>=2) dp[j][k]=(1ll*(j?dp[j-1][k-1]:0)+(k==n?dp[j][n]:0)+s[j+1][k])%mod;//有上限!!
else
{
dp[j][k]=0;
// dp[j][k]=(1ll*(j?dp[j-1][k-1]:0)+(k==n?dp[j][n]:0)+s[j+1][k])%mod;
// if(dp[j][k]) printf("(%d,%d,%d)\n",i,j,k);
}
}
for(int k=1;k<=n;++k)
for(int j=n-1;j>=0;--j)
s[j][k]=(s[j+1][k]+dp[j][k])%mod;
int res=0;
for(int k=1;k<=n;++k) res=(res+s[0][k])%mod;
printf("%d ",(res+mod)%mod);
}
printf("\n");
return ;
}
int main()
{
//freopen("Salaj.in","r",stdin);
//freopen("Salaj.out","w",stdout);
int T=read();
while(T--)
{
solve();
}
//fclose(stdin);
//fclose(stdout);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3476kb
input:
2 5 10 666013 6 9 10
output:
1 2 4 9 21 50 110 209 351 546 1 2 4 9 1 1 6 0 7
result:
ok 19 numbers
Test #2:
score: -100
Wrong Answer
time: 48ms
memory: 3552kb
input:
10 31 248 8654701 13 11 331266209 33 517 52876477 26 580 675225807 48 2029 311070528 26 31 327981899 39 25 644128037 29 776 464963196 43 799 451592950 25 184 564388620
output:
1 2 4 9 21 51 127 323 835 2188 5798 15511 41835 113634 310572 853467 2356779 6536382 889882 7578514 4072343 2646977 4649285 7797829 7894657 8630011 5369867 7539674 4332126 8201689 8589675 2709364 4018535 3531401 5490003 4890382 334630 1280966 7295275 4971992 1680824 7744560 2450701 2716471 1097918 5...
result:
wrong answer 1102nd numbers differ - expected: '546820274', found: '546820275'