Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
34386 | LYLAKIOI | 【S】T2 | C++ | 通过 | 100 | 217 MS | 16600 KB | 1267 | 2024-11-07 18:31:33 |
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define pi pair<int,int> #define p1 first #define p2 second #define m_p make_pair #define p_b push_back #define ppc __builtin_popcount using namespace std; typedef long long ll; const int maxn=1e6+10; inline ll read(){ ll x=0;short t=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')t=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; } int n,m,c,tg[1<<20]; vector<int>P[50]; int trans(){ int s=0;char ch=getchar(); while(ch<'0'||ch>'1')ch=getchar(); while(ch>='0'&&ch<='1')s=(s<<1)+ch-'0',ch=getchar(); return s; } void slv(){ n=read(),m=read(),c=read(); up(i,0,(1<<m)-1)P[ppc(i)].p_b(i); int res=0; up(i,1,n){ int x=trans(); if(i==1){res+=c;tg[x]=1;continue;} bool ok=0; up(j,0,min(c-2,m)){ for(int y:P[j])if(tg[x^y]){ok=1;res+=j+1;break;} if(ok)break; }if(!ok)res+=c; tg[x]=1; }cout<<res; } int main(){ //freopen("code.in","r",stdin); //freopen("code.out","w",stdout); slv(); fclose(stdin); fclose(stdout); return 0; }