| 比赛 |
寒假集训4 |
评测结果 |
MMMTMMMTMM |
| 题目名称 |
bitset(位集) |
最终得分 |
0 |
| 用户昵称 |
123 |
运行时间 |
4.734 s |
| 代码语言 |
C++ |
内存使用 |
239.31 MiB |
| 提交时间 |
2026-02-28 11:20:35 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
const int N=1e7+10;
int n,m,k,x,y,z;
vector<string> v;
vector<int> f[N];
map<pair<int,int>,int> mp;
void solve1()
{
int qx=1,qy=n,lst=0;
long long ans=0;
while (k--)
{
lst=0;
int l=min(qx,qy),r=max(qx,qy);
if (mp[{l,r}]) lst=mp[{l,r}];
else
{
for (int i=0;i<m;i++)
{
int now=(f[r][i]-(l==1 ? 0 : f[l-1][i]));
lst+=(now==0 || now==(r-l+1));
}
mp[{l,r}]=lst;
}
ans+=lst;
int a=(1ll*qx*x+1ll*lst*y+z)%n+1,b=(1ll*qy*y+1ll*lst*z+x)%n+1;
qx=a,qy=b;
}
cout<<ans;
}
int main() {
freopen("bitset.in","r",stdin);
freopen("bitset.out","w",stdout);
ios::sync_with_stdio(0),cin.tie(0);
cin>>n>>m;
for (int i=1;i<=n;i++)
{
string s;
cin>>s;
v.push_back(s);
}
for (int i=0;i<m;i++)
{
f[1].push_back(v[0][i]=='0');
for (int j=2;j<=n;j++) f[j].push_back(f[j-1][i]+(v[j-1][i]=='0'));
}
cin>>k>>x>>y>>z;
solve1();
}