QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#841925#9965. Game MPOucup-team3555#WA 0ms20368kbC++201.1kb2025-01-04 08:52:422025-01-04 08:52:42

Judging History

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

  • [2025-01-04 08:52:42]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:20368kb
  • [2025-01-04 08:52:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N=2e3+5,H=1e9+7;
int n,m,a[N],C[N][N],ct[N*N],s[2],res=0;

int adc(int a,int b){return a+b>=H?a+b-H:a+b;}
int dec(int a,int b){return a<b?a-b+H:a-b;}
int mul(int a,int b){return 1ll*a*b%H;}
void add(int &a,int b){a=adc(a,b);}
void del(int &a,int b){a=dec(a,b);}

int qpow(int a,int b=H-2){
  int res=1;
  while(b){if(b&1) res=mul(res,a);a=mul(a,a),b>>=1;}
  return res;
}

void init(){
  for(int i=0;i<N;i++){
    C[i][0]=1;
    for(int j=1;j<=i;j++) C[i][j]=adc(C[i-1][j-1],C[i-1][j]);
  }
}

int main(){
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>n>>m,init();
  for(int i=1;i<=n;i++) cin>>a[i],ct[a[i]]++;
  sort(a+1,a+n+1);
  
  for(int i=m;i>=1;i--) s[0]+=a[i]==a[m],res-=a[i];
  for(int i=n-m+1;i<=n;i++) s[1]+=a[i]==a[n-m+1],res+=a[i];      
  cout<<res<<" ";
  
  if(a[m]==a[n-m+1]){
    int tmp=mul(C[ct[a[m]]][s[0]],C[ct[a[m]]-s[0]][s[1]]);
    if(s[0]==s[1]&&s[0]==m) cout<<mul(tmp,qpow(2));
    else cout<<tmp;
  }else cout<<mul(C[ct[a[m]]][s[0]],C[ct[a[n-m+1]]][s[1]]);
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 20368kb

input:

4
.pm.
Mom.
OOm.
p..p

output:

0 500000004

result:

wrong answer 1st lines differ - expected: '4 13', found: '0 500000004'