原题传送门

根据题意,题目给的每个操作就相当于异或上选中的那几只虫子的足数(mod 2)等于0/1

这是一个异或方程组,珂以用高斯消元解出每个虫子的足数(mod 2)、所需最小次数或判断有多解

但是看题目数据范围\(n \leq 1000,m \leq 2000\),如果直接高斯消元\(O(n^2m)\)的话超时无疑

观察这题的个性:方程组中要通过上下行异或进行消元,这是位运算,一定珂以用bitset优化

我们对每一行开一个bitset,这样消元时直接把两行的bitset异或起来,复杂度为\(O(\frac{n^2m}{\omega})\)

#include <bits/stdc++.h>
#define N 1005
#define M 2005
#define getchar nc
using namespace std;
inline char nc(){
static char buf[100000],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read()
{
register int x=0,f=1;register char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
return x*f;
}
inline void write(register int x)
{
if(!x)putchar('0');if(x<0)x=-x,putchar('-');
static int sta[20];register int tot=0;
while(x)sta[tot++]=x%10,x/=10;
while(tot)putchar(sta[--tot]+48);
}
inline int Max(register int x,register int y)
{
return x>y?x:y;
}
bitset<N> b[M];
int n,m,now,ans;
int main()
{
n=read(),m=read();
for(register int i=1;i<=m;++i)
for(register int j=1;j<=n+1;++j)
{
char ch=getchar();
while(ch!='0'&&ch!='1')
ch=getchar();
b[i][j]=ch-'0';
}
for(register int i=1;i<=n;++i)
{
now=i;
while(now<=m&&!b[now][i])
++now;
if(now==m+1)
{
puts("Cannot Determine");
return 0;
}
ans=Max(ans,now);
if(now!=i)
swap(b[i],b[now]);
for(register int j=1;j<=m;++j)
{
if(i==j||!b[j][i])
continue;
b[j]^=b[i];
}
}
write(ans),puts("");
for(register int i=1;i<=n;++i)
if(b[i][n+1])
puts("?y7M#");
else
puts("Earth");
return 0;
}

最新文章

  1. linux下EOF写法梳理
  2. &lt;十五&gt;JDBC_使用 DBUtils 进行更新、查询操作
  3. 在Linux环境下,将Solr部署到tomcat7中,导入Mysql数据库数据, 定时更新索引
  4. ACM/ICPC 之 递归(POJ2663-完全覆盖+POJ1057(百练2775)-旧式文件结构图)
  5. 使用VS自带的报表RDLC结合报表控件ReportViewer使用
  6. openStack开源云repo db local or on-line 实战部署之Ruiy王者归来
  7. 为Tornado框架加上基于Redis或Memcached的session 【第三方】
  8. Unity性能优化的N种武器
  9. 等价于n*n的矩阵,填写0,1,要求每行每列的都有偶数个1 (没有1也是偶数个),问有多少种方法。
  10. poj 3090 Visible Lattice Points(离线打表)
  11. Python3 与 C# 基础语法对比(Function专栏)
  12. 如何在github上搭建一个免费的 无限流量的静态网页博客Github pages
  13. css动画 aniamtion &amp; @keyframes
  14. MyEclipse使用教程:在Web项目中使用Web片段
  15. ios数据保存
  16. 【Android开发】之Fragment生命周期
  17. sass的@at-root
  18. spring 接收前台ajax传来的参数的几个方法
  19. 如何修改Windows程序的权限?
  20. Angular js部分关键字的理解

热门文章

  1. Vue+element 修改样式的scoped穿透方法
  2. GNU autotools 安装和使用
  3. mybatis中的高级查询
  4. centos7.2下安装python3.6.5
  5. 用 Splashtop Wired XDisplay HD 让 ipad做电脑扩展屏幕__亲测有效
  6. CEF3相关知识汇总(不断更新)
  7. uiautomatorviewer
  8. Utterance-level Aggregation for Speaker Recognition in The Wild
  9. Python面向对象 | isinstance和issubclass
  10. IIS 报错 Cannot open database &quot;test4&quot; requested by the login. The login failed. Login failed for user &#39;IIS APPPOOL\test1&#39;.