Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
34540 baka24 【S】T3 C++ 通过 100 923 MS 126616 KB 1637 2024-11-10 18:31:01

Tests(10/10):


#include<bits/stdc++.h> using namespace std; #define pii pair<int,int> #define fr first #define sc second #define pb push_back #define lson (pos<<1) #define rson (pos<<1|1) #define popcnt __builtin_popcount int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;} const int MAXN=300010,N=35,M=24; int n,m,k,a[MAXN],f[N],t[N],C[N][N],cs[(1<<M)+10]; string ejz(int x){ string res=""; for(int i=0;i<n;i++)if(x&(1<<i))res+="1";else res+="0"; return res; } void slv(){ n=read(),m=read(),k=read(); for(int i=1;i<=m;i++){ for(int j=0;j<n;j++){ char c=getchar(); while(c!='0'&&c!='1')c=getchar(); if(c=='1')a[i]+=1<<j; } } C[0][0]=1; for(int i=1;i<=n;i++){C[i][0]=1;for(int j=1;j<=n;j++)C[i][j]=C[i-1][j]+C[i-1][j-1];} for(int i=k;i<=n;i++){ f[i]=1; for(int j=0;j<i;j++)f[i]-=f[j]*C[i][j]; } for(int i=1;i<=m;i++)cs[a[i]]++; for(int i=0;i<n;i++){ for(int j=0;j<1<<n;j++)if((j&(1<<i))==0){ cs[j]+=cs[j^(1<<i)]; } } for(int i=0;i<1<<n;i++)cs[i]*=f[popcnt(i)]; for(int i=0;i<n;i++){ for(int j=0;j<1<<n;j++)if((j&(1<<i))){ cs[j]+=cs[j^(1<<i)]; } } for(int i=0;i<1<<n;i++){ t[popcnt(i)]=max(t[popcnt(i)],cs[i]); } for(int i=1;i<=n;i++)t[i]=max(t[i],t[i-1]); for(int i=1,j=0;i<=m;i++){ while(j<=n&&t[j]<i)j++; printf("%d\n",j); } } signed main(){ slv(); return 0; }


测评信息: