QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#452549#8702. 狼人杀marher100 ✓1423ms31360kbC++141.3kb2024-06-23 19:17:172024-06-23 19:17:17

Judging History

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

  • [2024-06-23 19:17:17]
  • 评测
  • 测评结果:100
  • 用时:1423ms
  • 内存:31360kb
  • [2024-06-23 19:17:17]
  • 提交

answer

#pragma GCC optimize("Ofast","inline")
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=152,M=N*(N+1)/2,mod=1e9+7;

int n,m,f[N][M][2],t,inv[M],ans;

int ksm(int a,int b)
{
    int ans=1;
    while(b)
    {
        if(b&1)ans=ans*a%mod;
        b>>=1;a=a*a%mod;
    }
    return ans;
}

int g(int len)
{
    return len*(len+1)/2;
}

void ad(int&x,int y)
{
    x+=y;x-=x>=mod?mod:0;
}

void add(int s,int k)
{
    ad(ans,inv[k]*s%mod);
}

main()
{
    cin>>n>>m;t=g(n);m=min(m,n-m+1);
    for(int i=0;i<=t;i++)inv[i]=ksm(1+mod-i*ksm(t,mod-2)%mod,mod-2);
    for(int i=1;i<=m;i++)
    {
        memset(f,0,sizeof f);
        f[i][0][0]=mod-1;
        f[i][0][1]=(i-1)*(mod-1)%mod;
        for(int j=i;j<=n;j++)
        for(int k=0;k<=g(j-1);k++)
        for(int o=0;o<2;o++)if(f[j][k][o])
        {
            int s=f[j][k][o],u=j<m?m:n;
            if(j>=m)
            {
                if(o)add(s,k+g(i+n-j));
                else add(s*(n-j)%mod,k+g(i+n-j));
            }
            for(int p=j+1;p<=u;p++)
            {
                ad(f[p][k+g(p-j-1)][o],mod-s);
                if(!o)ad(f[p][k+g(p-j-1)][1],(mod-s)*(p-j-1)%mod);
            }
        }
    }
    cout<<ans*ksm(n-1,mod-2)%mod<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 23
Accepted

Test #1:

score: 23
Accepted
time: 0ms
memory: 31172kb

input:

12 2

output:

183756997

result:

ok single line: '183756997'

Test #2:

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

input:

17 6

output:

97571903

result:

ok single line: '97571903'

Test #3:

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

input:

13 3

output:

209826617

result:

ok single line: '209826617'

Test #4:

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

input:

13 8

output:

176038768

result:

ok single line: '176038768'

Test #5:

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

input:

18 4

output:

288404061

result:

ok single line: '288404061'

Test #6:

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

input:

10 10

output:

219657163

result:

ok single line: '219657163'

Test #7:

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

input:

19 15

output:

590577825

result:

ok single line: '590577825'

Test #8:

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

input:

11 6

output:

488143489

result:

ok single line: '488143489'

Test #9:

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

input:

10 5

output:

470594541

result:

ok single line: '470594541'

Test #10:

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

input:

20 5

output:

582458555

result:

ok single line: '582458555'

Test #11:

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

input:

20 12

output:

648081410

result:

ok single line: '648081410'

Test #12:

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

input:

20 4

output:

335777285

result:

ok single line: '335777285'

Test #13:

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

input:

20 15

output:

389216500

result:

ok single line: '389216500'

Test #14:

score: 0
Accepted
time: 10ms
memory: 31160kb

input:

20 16

output:

582458555

result:

ok single line: '582458555'

Test #15:

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

input:

20 19

output:

589126150

result:

ok single line: '589126150'

Test #16:

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

input:

20 6

output:

389216500

result:

ok single line: '389216500'

Subtask #2:

score: 34
Accepted

Dependency #1:

100%
Accepted

Test #17:

score: 34
Accepted
time: 20ms
memory: 31164kb

input:

49 14

output:

486918542

result:

ok single line: '486918542'

Test #18:

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

input:

28 13

output:

642223597

result:

ok single line: '642223597'

Test #19:

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

input:

35 23

output:

842346505

result:

ok single line: '842346505'

Test #20:

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

input:

47 11

output:

583647040

result:

ok single line: '583647040'

Test #21:

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

input:

34 30

output:

990970048

result:

ok single line: '990970048'

Test #22:

score: 0
Accepted
time: 13ms
memory: 31144kb

input:

30 7

output:

393675971

result:

ok single line: '393675971'

Test #23:

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

input:

43 5

output:

737421246

result:

ok single line: '737421246'

Test #24:

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

input:

30 21

output:

254760745

result:

ok single line: '254760745'

Test #25:

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

input:

27 22

output:

266692865

result:

ok single line: '266692865'

Test #26:

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

input:

40 12

output:

133652311

result:

ok single line: '133652311'

Test #27:

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

input:

29 4

output:

873892090

result:

ok single line: '873892090'

Test #28:

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

input:

50 46

output:

267950067

result:

ok single line: '267950067'

Test #29:

score: 0
Accepted
time: 16ms
memory: 31128kb

input:

50 11

output:

423642322

result:

ok single line: '423642322'

Test #30:

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

input:

50 43

output:

625476642

result:

ok single line: '625476642'

Test #31:

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

input:

50 36

output:

767166129

result:

ok single line: '767166129'

Test #32:

score: 0
Accepted
time: 19ms
memory: 31180kb

input:

50 14

output:

357467965

result:

ok single line: '357467965'

Test #33:

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

input:

50 30

output:

219673347

result:

ok single line: '219673347'

Test #34:

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

input:

50 44

output:

392786132

result:

ok single line: '392786132'

Test #35:

score: 0
Accepted
time: 16ms
memory: 31200kb

input:

50 10

output:

848251616

result:

ok single line: '848251616'

Subtask #3:

score: 43
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #36:

score: 43
Accepted
time: 64ms
memory: 31292kb

input:

75 47

output:

668751416

result:

ok single line: '668751416'

Test #37:

score: 0
Accepted
time: 78ms
memory: 31256kb

input:

75 41

output:

310834114

result:

ok single line: '310834114'

Test #38:

score: 0
Accepted
time: 366ms
memory: 31220kb

input:

133 124

output:

57167600

result:

ok single line: '57167600'

Test #39:

score: 0
Accepted
time: 700ms
memory: 31216kb

input:

129 74

output:

751074385

result:

ok single line: '751074385'

Test #40:

score: 0
Accepted
time: 149ms
memory: 31340kb

input:

135 133

output:

759430862

result:

ok single line: '759430862'

Test #41:

score: 0
Accepted
time: 75ms
memory: 31160kb

input:

75 19

output:

967921272

result:

ok single line: '967921272'

Test #42:

score: 0
Accepted
time: 258ms
memory: 31344kb

input:

124 9

output:

641081661

result:

ok single line: '641081661'

Test #43:

score: 0
Accepted
time: 57ms
memory: 31196kb

input:

76 66

output:

465902083

result:

ok single line: '465902083'

Test #44:

score: 0
Accepted
time: 614ms
memory: 31360kb

input:

142 13

output:

12401929

result:

ok single line: '12401929'

Test #45:

score: 0
Accepted
time: 349ms
memory: 31244kb

input:

150 5

output:

388058135

result:

ok single line: '388058135'

Test #46:

score: 0
Accepted
time: 189ms
memory: 31316kb

input:

109 97

output:

381109644

result:

ok single line: '381109644'

Test #47:

score: 0
Accepted
time: 942ms
memory: 31172kb

input:

150 133

output:

174431234

result:

ok single line: '174431234'

Test #48:

score: 0
Accepted
time: 278ms
memory: 31172kb

input:

150 147

output:

198921722

result:

ok single line: '198921722'

Test #49:

score: 0
Accepted
time: 597ms
memory: 31208kb

input:

150 142

output:

631473185

result:

ok single line: '631473185'

Test #50:

score: 0
Accepted
time: 877ms
memory: 31260kb

input:

150 136

output:

743180069

result:

ok single line: '743180069'

Test #51:

score: 0
Accepted
time: 768ms
memory: 31260kb

input:

150 138

output:

621574340

result:

ok single line: '621574340'

Test #52:

score: 0
Accepted
time: 1184ms
memory: 31220kb

input:

150 119

output:

872660153

result:

ok single line: '872660153'

Test #53:

score: 0
Accepted
time: 450ms
memory: 31348kb

input:

150 144

output:

939939060

result:

ok single line: '939939060'

Test #54:

score: 0
Accepted
time: 88ms
memory: 31228kb

input:

150 1

output:

166208360

result:

ok single line: '166208360'

Test #55:

score: 0
Accepted
time: 1423ms
memory: 31280kb

input:

150 75

output:

353929212

result:

ok single line: '353929212'