QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#279936#7873. Since A Lightzhouhuanyi18 111ms105584kbC++20934b2023-12-09 12:31:212023-12-09 12:31:21

Judging History

你现在查看的是最新测评结果

  • [2023-12-09 12:31:21]
  • 评测
  • 测评结果:18
  • 用时:111ms
  • 内存:105584kb
  • [2023-12-09 12:31:21]
  • 提交

answer

#include<iostream>
#include<cstdio>
#define N 5000
#define mod 998244353
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;
}
void Adder(int &x,int d)
{
	x+=d;
	if (x>=mod) x-=mod;
	return;
}
int n,d,cl[6][6],dp[N+1][N+1][6];
int main()
{
	n=read(),d=read();
	for (int op=0;op<=1;++op)
		for (int op2=0;op2<=1;++op2)
		{
			for (int op3=0;op3<=1-op;++op3)
				for (int op4=0;op4<=1-op2;++op4)
					cl[(op<<1)+op2][(op3<<1)+op4]=(!op&&!op3)+(!op2&&!op4)+1;
		}
	cl[1][4]=cl[4][4]=cl[4][5]=cl[5][4]=1,dp[0][0][0]=dp[0][0][1]=dp[0][0][2]=dp[0][0][3]=1;
	for (int i=1;i<=n;++i)
		for (int j=0;j<=d-1;++j)
			for (int k=0;k<6;++k)
				for (int t=0;t<6;++t)
					if (cl[k][t]&&j>=cl[k][t]-1)
						Adder(dp[i][j][t],dp[i-1][j-(cl[k][t]-1)][k]);
    printf("%d\n",dp[n][d-1][4]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 1
Accepted

Test #1:

score: 1
Accepted
time: 1ms
memory: 3856kb

input:

1 1

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

2 1

output:

2

result:

ok single line: '2'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3908kb

input:

3 2

output:

3

result:

ok single line: '3'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

4 4

output:

5

result:

ok single line: '5'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

5 7

output:

2

result:

ok single line: '2'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3844kb

input:

6 4

output:

41

result:

ok single line: '41'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

7 11

output:

2

result:

ok single line: '2'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

8 8

output:

175

result:

ok single line: '175'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

9 10

output:

298

result:

ok single line: '298'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

10 3

output:

392

result:

ok single line: '392'

Test #11:

score: 0
Accepted
time: 1ms
memory: 3832kb

input:

11 8

output:

3785

result:

ok single line: '3785'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3884kb

input:

12 15

output:

1422

result:

ok single line: '1422'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3864kb

input:

13 17

output:

2008

result:

ok single line: '2008'

Test #14:

score: 0
Accepted
time: 0ms
memory: 3960kb

input:

14 16

output:

21508

result:

ok single line: '21508'

Test #15:

score: 0
Accepted
time: 0ms
memory: 4020kb

input:

15 1

output:

1596

result:

ok single line: '1596'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3900kb

input:

16 28

output:

29

result:

ok single line: '29'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3896kb

input:

17 6

output:

98086

result:

ok single line: '98086'

Test #18:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

18 11

output:

1478534

result:

ok single line: '1478534'

Test #19:

score: 0
Accepted
time: 0ms
memory: 3980kb

input:

19 25

output:

250068

result:

ok single line: '250068'

Test #20:

score: 0
Accepted
time: 1ms
memory: 3928kb

input:

20 27

output:

355418

result:

ok single line: '355418'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

21 23

output:

13517834

result:

ok single line: '13517834'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3944kb

input:

22 4

output:

315460

result:

ok single line: '315460'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3896kb

input:

23 37

output:

18428

result:

ok single line: '18428'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

24 18

output:

647287901

result:

ok single line: '647287901'

Test #25:

score: 0
Accepted
time: 1ms
memory: 3964kb

input:

25 40

output:

136655

result:

ok single line: '136655'

Subtask #2:

score: 7
Accepted

Test #26:

score: 7
Accepted
time: 0ms
memory: 5872kb

input:

380 59

output:

718355613

result:

ok single line: '718355613'

Test #27:

score: 0
Accepted
time: 1ms
memory: 4596kb

input:

164 46

output:

353450103

result:

ok single line: '353450103'

Test #28:

score: 0
Accepted
time: 0ms
memory: 5304kb

input:

206 144

output:

910367339

result:

ok single line: '910367339'

Test #29:

score: 0
Accepted
time: 0ms
memory: 5724kb

input:

270 127

output:

78796015

result:

ok single line: '78796015'

Test #30:

score: 0
Accepted
time: 1ms
memory: 4728kb

input:

157 87

output:

705420296

result:

ok single line: '705420296'

Subtask #3:

score: 10
Accepted

Test #31:

score: 10
Accepted
time: 11ms
memory: 11740kb

input:

413 652

output:

170600118

result:

ok single line: '170600118'

Test #32:

score: 0
Accepted
time: 11ms
memory: 23336kb

input:

724 979

output:

677376486

result:

ok single line: '677376486'

Test #33:

score: 0
Accepted
time: 59ms
memory: 76888kb

input:

1667 1699

output:

147640784

result:

ok single line: '147640784'

Test #34:

score: 0
Accepted
time: 25ms
memory: 35732kb

input:

1980 517

output:

276583672

result:

ok single line: '276583672'

Test #35:

score: 0
Accepted
time: 111ms
memory: 105584kb

input:

2000 2000

output:

265422351

result:

ok single line: '265422351'

Subtask #4:

score: 0
Memory Limit Exceeded

Test #36:

score: 0
Memory Limit Exceeded

input:

4495 4498

output:

375585699

result:


Subtask #5:

score: 0
Runtime Error

Test #41:

score: 0
Runtime Error

input:

158314621 32

output:


result:


Subtask #6:

score: 0
Runtime Error

Test #46:

score: 0
Runtime Error

input:

812922977 1762

output:


result:


Subtask #7:

score: 0
Time Limit Exceeded

Test #51:

score: 0
Time Limit Exceeded

input:

320076133 78121

output:


result: