QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#18747#2115. Od deski do deski [A]The_Nobody4 4ms15760kbC++141.1kb2022-01-26 09:02:592022-05-06 02:21:20

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-06 02:21:20]
  • 评测
  • 测评结果:4
  • 用时:4ms
  • 内存:15760kb
  • [2022-01-26 09:02:59]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define Re register
#define Il inline
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define drep(i,a,b) for(ll i=(a);i>=(b);i--)
#define go(u) for(ll i=head[u],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define _go(u) for(ll i=Head[u],v=E[i].to;i;i=E[i].nxt,v=E[i].to)
#define writesp(x) write(x),putchar(' ')
#define writeln(x) write(x),puts("")
#define mem(x,v) memset(x,v,sizeof(x))
Il ll read(){ll sum=0,f=0;char ch=getchar();for(;!isdigit(ch);ch=getchar())f|=(ch=='-');for(;isdigit(ch);ch=getchar())sum=(sum<<1)+(sum<<3)+(ch^48);return f?-sum:sum;}
void write(ll x){if(x<0){putchar('-');write(-x);return;}if(x>=10)write(x/10);putchar(x%10+'0');}
char getc(){char ch=getchar();while(ch!='?'&&ch!='+'&&ch!='-')ch=getchar();return ch;}
using namespace std;
#define N 3300
ll f[N][N][2],n,m,mod=1e9+7;
int main(){
	n=read(),m=read();
	f[n+1][0][1]=1;
	drep(i,n,1)rep(j,0,m){
		f[i][j][1]=(f[i+1][j][0]+f[i+1][j][1])*j%mod;
		f[i][j][0]=f[i+1][j][0]*(m-j)%mod;if(j)f[i][j][0]=(f[i][j][0]+f[i+1][j-1][1]*(m-j+1))%mod;
	}
	ll ans=0;
	rep(i,1,m)ans=(ans+f[1][i][1])%mod;
	writeln(ans);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 1
Accepted

Test #1:

score: 1
Accepted
time: 2ms
memory: 3700kb

input:

4 2

output:

10

result:

ok single line: '10'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3592kb

input:

1 1

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3544kb

input:

1 3

output:

0

result:

ok single line: '0'

Test #4:

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

input:

1 5

output:

0

result:

ok single line: '0'

Test #5:

score: 0
Accepted
time: 3ms
memory: 3528kb

input:

2 2

output:

2

result:

ok single line: '2'

Test #6:

score: 0
Accepted
time: 3ms
memory: 3688kb

input:

2 4

output:

4

result:

ok single line: '4'

Test #7:

score: 0
Accepted
time: 3ms
memory: 3552kb

input:

3 1

output:

1

result:

ok single line: '1'

Test #8:

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

input:

3 3

output:

9

result:

ok single line: '9'

Test #9:

score: 0
Accepted
time: 3ms
memory: 3576kb

input:

3 5

output:

25

result:

ok single line: '25'

Test #10:

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

input:

4 2

output:

10

result:

ok single line: '10'

Test #11:

score: 0
Accepted
time: 3ms
memory: 3556kb

input:

4 4

output:

76

result:

ok single line: '76'

Test #12:

score: 0
Accepted
time: 3ms
memory: 3700kb

input:

5 1

output:

1

result:

ok single line: '1'

Test #13:

score: 0
Accepted
time: 3ms
memory: 3672kb

input:

5 3

output:

117

result:

ok single line: '117'

Test #14:

score: 0
Accepted
time: 3ms
memory: 3596kb

input:

5 5

output:

825

result:

ok single line: '825'

Test #15:

score: 0
Accepted
time: 2ms
memory: 3708kb

input:

7 2

output:

116

result:

ok single line: '116'

Test #16:

score: 0
Accepted
time: 4ms
memory: 3608kb

input:

9 2

output:

496

result:

ok single line: '496'

Test #17:

score: 0
Accepted
time: 3ms
memory: 3704kb

input:

11 2

output:

2028

result:

ok single line: '2028'

Test #18:

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

input:

13 2

output:

8168

result:

ok single line: '8168'

Test #19:

score: 0
Accepted
time: 3ms
memory: 3608kb

input:

10 3

output:

48237

result:

ok single line: '48237'

Subtask #2:

score: 1
Accepted

Test #20:

score: 1
Accepted
time: 3ms
memory: 3544kb

input:

1 2

output:

0

result:

ok single line: '0'

Test #21:

score: 0
Accepted
time: 3ms
memory: 3564kb

input:

1 4

output:

0

result:

ok single line: '0'

Test #22:

score: 0
Accepted
time: 3ms
memory: 3688kb

input:

2 1

output:

1

result:

ok single line: '1'

Test #23:

score: 0
Accepted
time: 2ms
memory: 3548kb

input:

2 3

output:

3

result:

ok single line: '3'

Test #24:

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

input:

2 5

output:

5

result:

ok single line: '5'

Test #25:

score: 0
Accepted
time: 2ms
memory: 3588kb

input:

3 2

output:

4

result:

ok single line: '4'

Test #26:

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

input:

3 4

output:

16

result:

ok single line: '16'

Test #27:

score: 0
Accepted
time: 3ms
memory: 3604kb

input:

4 1

output:

1

result:

ok single line: '1'

Test #28:

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

input:

4 3

output:

33

result:

ok single line: '33'

Test #29:

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

input:

4 5

output:

145

result:

ok single line: '145'

Test #30:

score: 0
Accepted
time: 3ms
memory: 3592kb

input:

5 2

output:

24

result:

ok single line: '24'

Test #31:

score: 0
Accepted
time: 3ms
memory: 3608kb

input:

5 4

output:

352

result:

ok single line: '352'

Test #32:

score: 0
Accepted
time: 2ms
memory: 3548kb

input:

6 2

output:

54

result:

ok single line: '54'

Test #33:

score: 0
Accepted
time: 2ms
memory: 3704kb

input:

8 2

output:

242

result:

ok single line: '242'

Test #34:

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

input:

10 2

output:

1006

result:

ok single line: '1006'

Test #35:

score: 0
Accepted
time: 3ms
memory: 3720kb

input:

12 2

output:

4074

result:

ok single line: '4074'

Test #36:

score: 0
Accepted
time: 3ms
memory: 3624kb

input:

14 2

output:

16358

result:

ok single line: '16358'

Subtask #3:

score: 1
Accepted

Test #37:

score: 1
Accepted
time: 2ms
memory: 10512kb

input:

1689 2

output:

998472085

result:

ok single line: '998472085'

Test #38:

score: 0
Accepted
time: 4ms
memory: 14688kb

input:

2748 2

output:

451726470

result:

ok single line: '451726470'

Test #39:

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

input:

1204 2

output:

449822862

result:

ok single line: '449822862'

Test #40:

score: 0
Accepted
time: 4ms
memory: 14640kb

input:

2727 2

output:

203224669

result:

ok single line: '203224669'

Test #41:

score: 0
Accepted
time: 2ms
memory: 7516kb

input:

984 2

output:

175698237

result:

ok single line: '175698237'

Test #42:

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

input:

3000 2

output:

165694478

result:

ok single line: '165694478'

Subtask #4:

score: 1
Accepted

Test #43:

score: 1
Accepted
time: 3ms
memory: 4088kb

input:

97 83

output:

613159502

result:

ok single line: '613159502'

Test #44:

score: 0
Accepted
time: 4ms
memory: 4200kb

input:

109 112

output:

749531455

result:

ok single line: '749531455'

Test #45:

score: 0
Accepted
time: 3ms
memory: 4024kb

input:

92 84

output:

754509307

result:

ok single line: '754509307'

Test #46:

score: 0
Accepted
time: 3ms
memory: 4236kb

input:

111 116

output:

434377961

result:

ok single line: '434377961'

Test #47:

score: 0
Accepted
time: 3ms
memory: 4080kb

input:

95 82

output:

345936119

result:

ok single line: '345936119'

Test #48:

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

input:

106 94

output:

551192069

result:

ok single line: '551192069'

Test #49:

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

input:

110 94

output:

41938476

result:

ok single line: '41938476'

Subtask #5:

score: 0
Runtime Error

Test #50:

score: 0
Runtime Error

input:

1168 346407973

output:


result:


Subtask #6:

score: 0
Runtime Error

Test #55:

score: 0
Runtime Error

input:

123 468402382

output:


result:


Subtask #7:

score: 0
Runtime Error

Test #60:

score: 0
Runtime Error

input:

779 140176290

output:


result:


Subtask #8:

score: 0
Runtime Error

Test #65:

score: 0
Runtime Error

input:

2315 21373850

output:


result:


Subtask #9:

score: 0
Runtime Error

Test #71:

score: 0
Runtime Error

input:

2631 684393357

output:


result:


Subtask #10:

score: 0
Runtime Error

Test #77:

score: 0
Runtime Error

input:

3000 1000000000

output:


result: