Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
34362 | liuyile | 【S】T2 | C++ | 通过 | 100 | 749 MS | 17512 KB | 925 | 2024-11-07 17:40:08 |
#include<bits/stdc++.h> using namespace std; #define int long long int n,m,c; int d[2000300]; queue<int>q; inline void upd(int x){ q.push(x); d[x]=0; while(!q.empty()){ int u=q.front(); q.pop(); if(d[u]>=c-1)continue; for(int i=0;i<m;i++){ int y=u^(1<<i);//666666666666 if(d[u]+1<d[y]){ d[y]=d[u]+1; q.push(y); } } } } signed main(){ ios::sync_with_stdio(0); cin.tie(0),cout.tie(0); // freopen("code.in","r",stdin); // freopen("code.out","w",stdout); cin>>n>>m>>c; memset(d,0x3f,sizeof(d)); int res=0; while(n--){ string s; int x=0; cin>>s; for(char p:s) x=x<<1|(p-'0'); res+=min(d[x]+1,c); upd(x); } cout<<res<<endl; cout.flush(); return 0; }