QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#103197 | #4794. Salaj | lyx123886a123886 | WA | 2ms | 3468kb | C++14 | 1.3kb | 2023-05-04 18:41:42 | 2023-05-04 18:41:43 |
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-j-1)/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(i==2&&dp[j][k]) printf("(%d,%d)\n",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: 0
Wrong Answer
time: 2ms
memory: 3468kb
input:
2 5 10 666013 6 9 10
output:
1 2 4 6 10 18 29 29 29 29 1 2 4 9 1 2 9 0 4
result:
wrong answer 4th numbers differ - expected: '9', found: '6'