Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
34467 | swzzzz | 【S】T2 | C++ | 通过 | 100 | 647 MS | 5156 KB | 855 | 2024-11-08 11:08:55 |
#include<bits/stdc++.h> using namespace std; #define N 1500006 int n,m,c,nn; int ans; int read(){ int res=0; char ch='0'; while (isdigit(ch)) { res<<=1; res|=(ch-'0'); ch=getchar(); } return res; } int dp[N]; void bfs(int x){ queue<int>q; dp[x]=1; q.push(x); while (!q.empty()) { int now=q.front(); q.pop(); for(int i=1;i<nn;i<<=1){ int to=now^i; if(dp[to]>dp[now]+1){ dp[to]=dp[now]+1; q.push(to); } } } } int main(){ cin>>n>>m>>c; nn=1<<m; for(int i=0;i<nn;i++) dp[i]=c; getchar(); int tmp; for(int i=1;i<=n;i++){ tmp=read(); ans+=dp[tmp]; bfs(tmp); } cout<<ans; return 0; }