QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#392323#6. 玛里苟斯marherCompile Error//C++141.8kb2024-04-17 14:35:342024-04-17 14:35:35

Judging History

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

  • [2024-04-17 14:35:35]
  • 评测
  • [2024-04-17 14:35:34]
  • 提交

answer

#include<bits/stdc++.h>
#define int unsigned long long
#define ll long long
using namespace std;
const int N=2e5+500;

int n,a[N],k;
long double ans,p[50];
__int128 res,z=1;

void sol()
{
    cout<<(int)(res/2);
    if(res&1)cout<<".5";
}

void sub1()
{
    for(int i=0;i<=63;i++)if(q[i])a[++n]=q[i];
    for(int i=0;i<64;i++)
    {
        int f=0;
        for(int j=1;j<=n;j++)if((a[j]>>i)&1)f=1;
        if(f)res+=(z<<i);
    }
    sol();
}

int g[8];

void sub2()
{
    for(int i=0;i<=63;i++)if(q[i])a[++n]=q[i];
    for(int i=0;i<32;i++)
    for(int j=i;j<32;j++)
    {
        memset(g,0,sizeof g);
        for(int x=1;x<=n;x++)
        {
            int w=0;
            if((a[x]>>i)&1)w|=2;
            if((a[x]>>j)&1)w|=1;
            ++g[w];
        }
        int cnt=(g[1]==0)+(g[2]==0);
        if(cnt&&!g[3])continue;
        if(i==j)
        {
            res+=(z<<i+j);
            continue;
        }
        if(cnt)res+=(z<<i+j)*(z<<cnt-1);
        else res+=(z<<i+j);
    }
    sol();
}

int q[50],sum[1<<23];

void sub3()
{
    for(int i=0;i<=63;i++)if(q[i])sum[1<<n]=q[i],a[n++]=q[i];
    for(ll i=1;i<(1<<n);i++)
    {
        if(!sum[i])
        {
            int lb=i&(-i);
            sum[i]=sum[i^lb]^sum[lb];
        }
        __int128 x=1;
        for(int j=1;j<=k;j++)x*=sum[i];
        res+=x;
    }
    res>>=(n-1);
    sol();
}

main()
{
    // freopen("in","r",stdin);
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)
    {
        int x=a[i];
        for(ll j=63;j>=0;j--)if((x>>j)&1)
        {
            if(!q[j])
            {
                q[j]=x;
                break;
            }
            x^=q[j];
        }
    }
    n=0;
    if(k==1)sub1();
    if(k==2)sub2();
    if(k>=3)sub3();
}

Details

answer.code: In function ‘void sub1()’:
answer.code:19:30: error: ‘q’ was not declared in this scope
   19 |     for(int i=0;i<=63;i++)if(q[i])a[++n]=q[i];
      |                              ^
answer.code: In function ‘void sub2()’:
answer.code:33:30: error: ‘q’ was not declared in this scope
   33 |     for(int i=0;i<=63;i++)if(q[i])a[++n]=q[i];
      |                              ^
answer.code: At global scope:
answer.code:78:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   78 | main()
      | ^~~~