QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#771333#9735. Japanese BandsSGColinCompile Error//C++142.0kb2024-11-22 11:50:332024-11-22 11:50:33

Judging History

This is the latest submission verdict.

  • [2025-01-18 23:34:05]
  • hack成功,自动添加数据
  • (/hack/1459)
  • [2024-11-22 11:50:33]
  • Judged
  • [2024-11-22 11:50:33]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod=1000000007;

int m1[1<<20],m2[1<<20];

int inv[30];
int invf(int a){
    a %= mod;
    int b=mod-2;
    int res = 1;
    while (b > 0) {
        if (b & 1) res = 1ll*res * a%mod;
        a = 1ll*a * a%mod;
        b >>= 1;
    }
    return res;
}

int calc(int n,int m){
    if(m>n){return 0;}
    if(m<0){return 0;}
    int ans=1;
    for(int i=1;i<=m;i++){
        ans=1ll*ans*(n-i+1)%mod;
        ans=1ll*ans*inv[i]%mod;
    }
    return ans;
}

set<int> s1;

int arr[410][2];

int main() {
    inv[0]=1;
    for(int i=1;i<=20;i++){
        inv[i]=1ll*i*inv[i-1]%mod;
    }
    for(int i=1;i<=20;i++){
        inv[i]=invf(inv[i]);
    }
    int t;scanf("%d",&t);
    while(t--){
        int n1,n2,m,k;scanf("%d%d%d%d",&n1,&n2,&m,&k);
        s1.clear();
        memset(m1,0,sizeof(m1));
        memset(m2,0,sizeof(m2));
        memset(arr,0,sizeof(arr));
        for(int i=1;i<=k;i++){
            scanf("%d%d",&arr[i][0],&arr[i][1]);
            arr[i][0]--;arr[i][1]--;
            s1.insert(arr[i][0]);
            s1.insert(arr[i][1]);
        }
        int M=s1.size();
        bool flag=true;
        for(int i=0;i<(1<<M);i++){
            flag=true;
            int num=0,temp=i;
            while(temp){
                if(temp&1){num++;}
                temp>>=1;
            }
            for(int j=1;j<=k;j++){
                if(((i>>arr[j][0])&1)&&((i>>arr[j][1])&1)){
                    flag=false;break;
                }
            }
            if(flag){
                m1[i]=calc(n2-1+m-M,m-num-1);
                m2[i]=calc(n1-1+m-M,m-num-1);
            }
        }
        for(int j = 0; j < M; j++) 
            for(int i = 0; i < 1 << M; i++)
                if(i >> j & 1) m2[i] = (1ll*m2[i]+m2[i ^ (1 << j)])%mod;
        int ans=0;
        for(int i=0;i<(1<<M);i++){
            int j=((1<<M)-1)^i;
            ans=(1ll*ans+m1[i]*m2[j])%mod;
        }
    

Details

answer.code: In function ‘int main()’:
answer.code:83:10: error: expected ‘}’ at end of input
   83 |         }
      |          ^
answer.code:45:15: note: to match this ‘{’
   45 |     while(t--){
      |               ^
answer.code:83:10: error: expected ‘}’ at end of input
   83 |         }
      |          ^
answer.code:36:12: note: to match this ‘{’
   36 | int main() {
      |            ^
answer.code:44:16: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   44 |     int t;scanf("%d",&t);
      |           ~~~~~^~~~~~~~~
answer.code:46:28: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   46 |         int n1,n2,m,k;scanf("%d%d%d%d",&n1,&n2,&m,&k);
      |                       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:52:18: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   52 |             scanf("%d%d",&arr[i][0],&arr[i][1]);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~