QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#32211#2573. Two PermutationsRobeZH#AC ✓171ms12092kbC++740b2022-05-18 01:59:552022-05-18 01:59:56

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-18 01:59:56]
  • 评测
  • 测评结果:AC
  • 用时:171ms
  • 内存:12092kb
  • [2022-05-18 01:59:55]
  • 提交

answer

#include<bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const int N = 102,mod=1e9+7;
int a[2][N][N*N];
int n,k;
int main() {
    scanf("%d%d",&n,&k);
    //n=100,k=5050;
    a[1][0][0]=1;
    for(int siz=n;siz;--siz)
        for(int typ=0;typ<2;++typ){
            memset(a[typ],0,sizeof a[typ]);
            for(int i=max(0,n-2*siz+typ);i<=min(n,n-siz+typ);++i)
                for(int j=0;j<=n*n;++j){
                    a[typ][i+1][j]=(a[typ][i+1][j]+(ll)a[typ^1][i][j]*(n-siz+typ-i))%mod;
                    a[typ][i][j+siz]=(a[typ][i][j+siz]+(ll)a[typ^1][i][j]*(siz-(n-siz+typ-i)))%mod;
                }
        }
    printf("%d\n",a[1][n][k]);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 11996kb

input:

2 4

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

3 7

output:

12

result:

ok 1 number(s): "12"

Test #3:

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

input:

4 10

output:

24

result:

ok 1 number(s): "24"

Test #4:

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

input:

4 14

output:

96

result:

ok 1 number(s): "96"

Test #5:

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

input:

5 10

output:

0

result:

ok 1 number(s): "0"

Test #6:

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

input:

5 15

output:

120

result:

ok 1 number(s): "120"

Test #7:

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

input:

5 21

output:

2400

result:

ok 1 number(s): "2400"

Test #8:

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

input:

6 21

output:

720

result:

ok 1 number(s): "720"

Test #9:

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

input:

6 30

output:

25920

result:

ok 1 number(s): "25920"

Test #10:

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

input:

6 27

output:

106560

result:

ok 1 number(s): "106560"

Test #11:

score: 0
Accepted
time: 6ms
memory: 12076kb

input:

20 300

output:

644873710

result:

ok 1 number(s): "644873710"

Test #12:

score: 0
Accepted
time: 8ms
memory: 12060kb

input:

20 139

output:

0

result:

ok 1 number(s): "0"

Test #13:

score: 0
Accepted
time: 12ms
memory: 12012kb

input:

30 470

output:

491424690

result:

ok 1 number(s): "491424690"

Test #14:

score: 0
Accepted
time: 17ms
memory: 12060kb

input:

30 500

output:

8436035

result:

ok 1 number(s): "8436035"

Test #15:

score: 0
Accepted
time: 18ms
memory: 12044kb

input:

40 1000

output:

617159088

result:

ok 1 number(s): "617159088"

Test #16:

score: 0
Accepted
time: 18ms
memory: 12048kb

input:

40 900

output:

729805907

result:

ok 1 number(s): "729805907"

Test #17:

score: 0
Accepted
time: 39ms
memory: 11992kb

input:

60 1830

output:

16340084

result:

ok 1 number(s): "16340084"

Test #18:

score: 0
Accepted
time: 40ms
memory: 11928kb

input:

60 2000

output:

832198921

result:

ok 1 number(s): "832198921"

Test #19:

score: 0
Accepted
time: 169ms
memory: 12040kb

input:

100 5050

output:

437918130

result:

ok 1 number(s): "437918130"

Test #20:

score: 0
Accepted
time: 167ms
memory: 12044kb

input:

100 700

output:

0

result:

ok 1 number(s): "0"

Test #21:

score: 0
Accepted
time: 171ms
memory: 11972kb

input:

100 10000

output:

0

result:

ok 1 number(s): "0"