QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#18221 | #2115. Od deski do deski [A] | Appleblue17# | 2 | 3ms | 10420kb | C++ | 425b | 2022-01-16 20:49:16 | 2022-05-04 17:22:19 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1100,mod=1e9+7;
int n,m,ans;
int dp[N][N][2];
int main(){
cin>>n>>m;
dp[0][0][1]=1;
for(int i=1;i<=n;i++){
for(int j=0;j<=n;j++){
dp[i][j][1]=(dp[i-1][j][1]+dp[i-1][j][0])%mod*j%mod;
if(j) dp[i][j][0]=(1ll*dp[i-1][j-1][1]*(m-j+1)%mod+1ll*dp[i-1][j][0]*(m-j)%mod)%mod;
}
}
for(int i=0;i<=n;i++) ans=(ans+dp[n][i][1])%mod;
cout<<ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 1
Accepted
Test #1:
score: 1
Accepted
time: 3ms
memory: 3536kb
input:
4 2
output:
10
result:
ok single line: '10'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3568kb
input:
1 1
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3576kb
input:
1 3
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3456kb
input:
1 5
output:
0
result:
ok single line: '0'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3576kb
input:
2 2
output:
2
result:
ok single line: '2'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
2 4
output:
4
result:
ok single line: '4'
Test #7:
score: 0
Accepted
time: 3ms
memory: 3600kb
input:
3 1
output:
1
result:
ok single line: '1'
Test #8:
score: 0
Accepted
time: 3ms
memory: 3668kb
input:
3 3
output:
9
result:
ok single line: '9'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3604kb
input:
3 5
output:
25
result:
ok single line: '25'
Test #10:
score: 0
Accepted
time: 3ms
memory: 3672kb
input:
4 2
output:
10
result:
ok single line: '10'
Test #11:
score: 0
Accepted
time: 3ms
memory: 3604kb
input:
4 4
output:
76
result:
ok single line: '76'
Test #12:
score: 0
Accepted
time: 3ms
memory: 3608kb
input:
5 1
output:
1
result:
ok single line: '1'
Test #13:
score: 0
Accepted
time: 3ms
memory: 3692kb
input:
5 3
output:
117
result:
ok single line: '117'
Test #14:
score: 0
Accepted
time: 3ms
memory: 3692kb
input:
5 5
output:
825
result:
ok single line: '825'
Test #15:
score: 0
Accepted
time: 3ms
memory: 3684kb
input:
7 2
output:
116
result:
ok single line: '116'
Test #16:
score: 0
Accepted
time: 0ms
memory: 5640kb
input:
9 2
output:
496
result:
ok single line: '496'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
11 2
output:
2028
result:
ok single line: '2028'
Test #18:
score: 0
Accepted
time: 1ms
memory: 3644kb
input:
13 2
output:
8168
result:
ok single line: '8168'
Test #19:
score: 0
Accepted
time: 2ms
memory: 3636kb
input:
10 3
output:
48237
result:
ok single line: '48237'
Subtask #2:
score: 1
Accepted
Test #20:
score: 1
Accepted
time: 3ms
memory: 3576kb
input:
1 2
output:
0
result:
ok single line: '0'
Test #21:
score: 0
Accepted
time: 3ms
memory: 3600kb
input:
1 4
output:
0
result:
ok single line: '0'
Test #22:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
2 1
output:
1
result:
ok single line: '1'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
2 3
output:
3
result:
ok single line: '3'
Test #24:
score: 0
Accepted
time: 3ms
memory: 3692kb
input:
2 5
output:
5
result:
ok single line: '5'
Test #25:
score: 0
Accepted
time: 3ms
memory: 3468kb
input:
3 2
output:
4
result:
ok single line: '4'
Test #26:
score: 0
Accepted
time: 3ms
memory: 3596kb
input:
3 4
output:
16
result:
ok single line: '16'
Test #27:
score: 0
Accepted
time: 3ms
memory: 3472kb
input:
4 1
output:
1
result:
ok single line: '1'
Test #28:
score: 0
Accepted
time: 3ms
memory: 3688kb
input:
4 3
output:
33
result:
ok single line: '33'
Test #29:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
4 5
output:
145
result:
ok single line: '145'
Test #30:
score: 0
Accepted
time: 3ms
memory: 3620kb
input:
5 2
output:
24
result:
ok single line: '24'
Test #31:
score: 0
Accepted
time: 3ms
memory: 3612kb
input:
5 4
output:
352
result:
ok single line: '352'
Test #32:
score: 0
Accepted
time: 3ms
memory: 3480kb
input:
6 2
output:
54
result:
ok single line: '54'
Test #33:
score: 0
Accepted
time: 3ms
memory: 3592kb
input:
8 2
output:
242
result:
ok single line: '242'
Test #34:
score: 0
Accepted
time: 2ms
memory: 3616kb
input:
10 2
output:
1006
result:
ok single line: '1006'
Test #35:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
12 2
output:
4074
result:
ok single line: '4074'
Test #36:
score: 0
Accepted
time: 3ms
memory: 3616kb
input:
14 2
output:
16358
result:
ok single line: '16358'
Subtask #3:
score: 0
Runtime Error
Test #37:
score: 0
Runtime Error
input:
1689 2
output:
result:
Subtask #4:
score: 0
Wrong Answer
Test #43:
score: 0
Wrong Answer
time: 3ms
memory: 4020kb
input:
97 83
output:
141341373
result:
wrong answer 1st lines differ - expected: '613159502', found: '141341373'
Subtask #5:
score: 0
Runtime Error
Test #50:
score: 0
Runtime Error
input:
1168 346407973
output:
result:
Subtask #6:
score: 0
Wrong Answer
Test #55:
score: 0
Wrong Answer
time: 3ms
memory: 4128kb
input:
123 468402382
output:
837845523
result:
wrong answer 1st lines differ - expected: '827499041', found: '837845523'
Subtask #7:
score: 0
Wrong Answer
Test #60:
score: 0
Wrong Answer
time: 2ms
memory: 10420kb
input:
779 140176290
output:
-608979423
result:
wrong answer 1st lines differ - expected: '438118426', found: '-608979423'
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