QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#617735#7662. Kaldorian Knights7islandsWA 6ms13860kbC++231.1kb2024-10-06 16:49:452024-10-06 16:49:47

Judging History

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

  • [2024-10-06 16:49:47]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:13860kb
  • [2024-10-06 16:49:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=0x3f3f3f3f;
const ll infll=0x3f3f3f3f3f3f3f3f;
#define int long long
#define pii pair <int,int>
#define ld long double
#define endl "\n"
const int N=200050;
const int mod=1e9+7;
int a[N];
int frac[1000050];
int fracsf[1000050];
signed main (){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    cin >>n;
    int h;
    cin >>h;
    frac[0]=1;
    frac[1]=1;
    for (int i=2;i<=1000025;i++){
        frac[i]=frac[i-1]*i;
        frac[i]%=mod;

    }
   // cerr <<1<<endl;
    for (int i=1;i<=h;i++){
        cin >>a[i];
    }
   // cerr <<1<<endl;
    int sum=0;
    int sig=0;
    int sig2=0;
    for (int i=1;i<=h;i++){
        int presig=sig;
        sig+=a[i];
      //  cerr <<sig<<endl;
        sum+=frac[sig]*frac[n-sig];
        sum%=mod;
        if (i!=1)sig2+=((frac[a[i]]*frac[n-sig])%mod*frac[presig])%mod;
        sig2%=mod;
        sum-=sig2;
        sum+=mod*2;
        sum%=mod;
        //cout <<sum<<endl;
    }
    cout <<(mod+frac[n]-sum)%mod<<endl;

}

詳細信息

Test #1:

score: 100
Accepted
time: 6ms
memory: 12296kb

input:

3 0

output:

6

result:

ok single line: '6'

Test #2:

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

input:

4 1
3

output:

18

result:

ok single line: '18'

Test #3:

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

input:

4 2
2
1

output:

16

result:

ok single line: '16'

Test #4:

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

input:

10 1
10

output:

0

result:

ok single line: '0'

Test #5:

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

input:

10 10
1
1
1
1
1
1
1
1
1
1

output:

0

result:

ok single line: '0'

Test #6:

score: -100
Wrong Answer
time: 6ms
memory: 13860kb

input:

1357 7
56
173
21
103
96
149
38

output:

80518359

result:

wrong answer 1st lines differ - expected: '1000000006', found: '80518359'