QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#306081 | #8015. 鸡 | zhouhuanyi | 25 | 34ms | 23860kb | C++14 | 1.3kb | 2024-01-16 12:15:52 | 2024-01-16 12:15:52 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<set>
#define N 4000
using namespace std;
int read()
{
char c=0;
int sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
int n,m,mod,a[N+1],dp[N+1],dp2[N+1],DP[N+1][N+1],F[N+1];
int MD(int x)
{
return x>=mod?x-mod:x;
}
void Adder(int &x,int d)
{
x+=d;
if (x>=mod) x-=mod;
return;
}
struct reads
{
int d[N+1];
bool operator < (const reads &t)const
{
for (int i=1;i<=n;++i)
if (d[i]!=t.d[i])
return d[i]<t.d[i];
return 0;
}
};
reads sx;
set<reads>s;
void dfs(int x)
{
if (x==n+1)
{
for (int i=1;i<=n;++i) dp[i]=max(dp[i-1],dp[max(i-2,0)]+a[i]);
for (int i=n;i>=1;--i) dp2[i]=max(dp2[i+1],dp2[i+2]+a[i]);
for (int i=1;i<=n;++i) sx.d[i]=dp[i-1]+dp2[i+1];
s.insert(sx);
return;
}
for (int i=0;i<=m;++i) a[x]=i,dfs(x+1);
return;
}
int main()
{
n=read(),m=read(),mod=read();
if (n<=5&&m<=5) dfs(1),printf("%d\n",s.size());
else
{
for (int i=5;i<=n+3;++i) F[i]=(i-3)>>1;
DP[0][0]=1;
for (int i=1;i<=n+3;++i)
for (int j=2;j<=i;++j)
{
Adder(DP[i][0],DP[i-j][0]);
Adder(DP[i][1],DP[i-j][1]);
Adder(DP[i][1],1ll*DP[i-j][0]*F[j]%mod);
}
printf("%d\n",MD(DP[n+3][0]+DP[n+3][1]));
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 5
Accepted
time: 4ms
memory: 23860kb
input:
5 5 1004326439
output:
1281
result:
ok 1 number(s): "1281"
Test #2:
score: 5
Accepted
time: 0ms
memory: 13968kb
input:
5 4 1002682123
output:
649
result:
ok 1 number(s): "649"
Test #3:
score: 5
Accepted
time: 1ms
memory: 5008kb
input:
287 1 1003060133
output:
328406329
result:
ok 1 number(s): "328406329"
Test #4:
score: 5
Accepted
time: 0ms
memory: 4976kb
input:
279 1 1004432189
output:
222258837
result:
ok 1 number(s): "222258837"
Test #5:
score: 5
Accepted
time: 1ms
memory: 5060kb
input:
300 1 1005912203
output:
707086810
result:
ok 1 number(s): "707086810"
Test #6:
score: 0
Wrong Answer
time: 0ms
memory: 5012kb
input:
288 5 1003307827
output:
302624836
result:
wrong answer 1st numbers differ - expected: '964512417', found: '302624836'
Test #7:
score: 0
Wrong Answer
time: 1ms
memory: 4920kb
input:
281 5 1008854383
output:
471801009
result:
wrong answer 1st numbers differ - expected: '755282155', found: '471801009'
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 4876kb
input:
270 5 1007619367
output:
330443256
result:
wrong answer 1st numbers differ - expected: '431828317', found: '330443256'
Test #9:
score: 0
Wrong Answer
time: 1ms
memory: 5088kb
input:
292 5 1002449813
output:
530615262
result:
wrong answer 1st numbers differ - expected: '183613546', found: '530615262'
Test #10:
score: 0
Wrong Answer
time: 1ms
memory: 5060kb
input:
300 5 1005897091
output:
85483324
result:
wrong answer 1st numbers differ - expected: '915308166', found: '85483324'
Test #11:
score: 0
Wrong Answer
time: 0ms
memory: 4108kb
input:
45 50 1009100993
output:
920710816
result:
wrong answer 1st numbers differ - expected: '940158800', found: '920710816'
Test #12:
score: 0
Wrong Answer
time: 0ms
memory: 4052kb
input:
49 50 1001428049
output:
395802997
result:
wrong answer 1st numbers differ - expected: '1045902', found: '395802997'
Test #13:
score: 0
Wrong Answer
time: 0ms
memory: 4056kb
input:
49 50 1007851073
output:
600776070
result:
wrong answer 1st numbers differ - expected: '922264698', found: '600776070'
Test #14:
score: 0
Wrong Answer
time: 0ms
memory: 4092kb
input:
50 50 1005625571
output:
509017421
result:
wrong answer 1st numbers differ - expected: '442192770', found: '509017421'
Test #15:
score: 0
Wrong Answer
time: 1ms
memory: 5032kb
input:
290 300 1005068699
output:
357713920
result:
wrong answer 1st numbers differ - expected: '484359497', found: '357713920'
Test #16:
score: 0
Wrong Answer
time: 1ms
memory: 4952kb
input:
270 300 1003440637
output:
827092018
result:
wrong answer 1st numbers differ - expected: '899894137', found: '827092018'
Test #17:
score: 0
Wrong Answer
time: 1ms
memory: 5044kb
input:
300 300 1008561979
output:
487732214
result:
wrong answer 1st numbers differ - expected: '33407754', found: '487732214'
Test #18:
score: 0
Wrong Answer
time: 31ms
memory: 15784kb
input:
2991 3000 1004658859
output:
219628850
result:
wrong answer 1st numbers differ - expected: '167444547', found: '219628850'
Test #19:
score: 0
Wrong Answer
time: 28ms
memory: 15372kb
input:
2870 3000 1004054173
output:
165711518
result:
wrong answer 1st numbers differ - expected: '860666062', found: '165711518'
Test #20:
score: 0
Wrong Answer
time: 34ms
memory: 15940kb
input:
3000 3000 1009539589
output:
558748869
result:
wrong answer 1st numbers differ - expected: '696222334', found: '558748869'