QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#664808 | #6611. United in Stormwind | Dixiky_215 | WA | 11ms | 109864kb | C++20 | 1.8kb | 2024-10-21 22:27:59 | 2024-10-21 22:28:00 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'