QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#664808#6611. United in StormwindDixiky_215WA 11ms109864kbC++201.8kb2024-10-21 22:27:592024-10-21 22:28:00

Judging History

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

  • [2024-10-21 22:28:00]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:109864kb
  • [2024-10-21 22:27:59]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int MAXN=(1<<21)+10;
#define ll long long
int n,m;
string bb[MAXN];
ll a[MAXN],b[MAXN],ta[MAXN],tb[MAXN],k;
ll f[MAXN],g[MAXN];
int s[MAXN];
void FWTxor(ll a[],long long type)
{
    int i,j,k,x,y;
    for(i=1;i<=m;i++)
    {
        for(j=0;j<(1<<m);j+=1<<i)
        {
            for(k=0;k<(1<<i-1);k++)
            {
                x=(a[j|k]+a[j|(1<<i-1)|k])*type;
                y=(a[j|k]-a[j|(1<<i-1)|k])*type,
                a[j|k]=x,a[j|(1<<i-1)|k]=y;
            }
        }
    }
    return;
}
void FWTxork(ll a[])
{
    int i,j,k,x,y;
    for(i=1;i<=m;i++)
    {
        for(j=0;j<(1<<m);j+=1<<i)
        {
            for(k=0;k<(1<<i-1);k++)
            {
                x=(a[j|k]+a[j|(1<<i-1)|k])/2;
                y=(a[j|k]-a[j|(1<<i-1)|k])/2,
                a[j|k]=x,a[j|(1<<i-1)|k]=y;
            }
        }
    }
    return;
}

int main()
{
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)
    {
        cin>>bb[i];
        int sss=0;
        for(int j=0;j<m;j++)
        {
            if(bb[i][j]=='A') sss+=(1<<j);
        }
        s[i]=sss;
        a[sss]++;
    }
    for(int i=0;i<(1<<m);i++) b[i]=a[i];
    memcpy(ta,a,sizeof a);memcpy(tb,b,sizeof b);
    FWTxor(ta,1);FWTxor(tb,1);
    for(int i=0;i<(1<<m);i++)ta[i]=(long long)ta[i]*tb[i];
    FWTxork(ta);
    f[0]-=n;
    for(int i=0;i<(1<<m);i++) f[i]=ta[i];
    
    int lim=(1<<m)-1;
    for(int i=0;i<(1<<m);i++) f[i]/=2LL;
    
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<(1<<m);j++)
        {
            if(j&(1<<i)) f[j]+=f[j^(1<<i)];
        }
    }
    ll ans=0;
    for(int i=1;i<(1<<m);i++)
    {
        ll sumk=(ll) n*(ll) (n-1LL)/2LL;
        if(sumk-f[i^lim]>=k) ans++;
    }
    cout<<ans;
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 11ms
memory: 109864kb

input:

2 2 1
AA
BB

output:

0

result:

wrong answer 1st numbers differ - expected: '3', found: '0'