BZOJ 1923 SDOI2010 外星千足虫 异或方程组+bitset
2024-10-27 14:34:34
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1923
懒得贴题目了......这就是解一个异或方程组的裸题......
YY了一下异或方程就没毛病了!
感受了一下bitset的力量噢噢噢!!!!!!
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<cctype>
#include<bitset>
using namespace std;
const int maxn=;
const int maxm=; int N,M;
bool b[maxm],x[maxm];
char s[maxn];
bitset<maxn>a[maxm]; void data_in()
{
scanf("%d%d",&N,&M);
for(int i=;i<=M;i++){
scanf("%s",s+);
for(int j=;j<=N;j++) a[i][j]=s[j]-'';
scanf("%s",s+);
b[i]=s[]-'';
}
}
int Gauss()
{
int i=,j=,re=;
while(i<=M&&j<=N){
re=max(re,i);
if(!a[i][j]){
int tmp=;
for(int r=i+;r<=M;r++)
if(a[r][j]) { tmp=r; break; }
if(!tmp) return ;
re=max(re,tmp);
swap(a[i],a[tmp]); swap(b[i],b[tmp]);
}
for(int r=i+;r<=M;r++){
if(!a[r][j]) continue;
a[r]^=a[i],b[r]^=b[i];
}
i++,j++;
}
if(j<=N) return ;
for(int r=N;r>=;r--){
x[r]=b[r];
for(int rr=r-;rr>=;rr--)
b[rr]^=*a[rr][r]*x[r];
}
return re;
}
void work()
{
int ans=;
if(ans=Gauss()){
printf("%d\n",ans);
for(int i=;i<=N;i++)
puts(x[i]?"?y7M#":"Earth");
}
else puts("Cannot Determine");
}
int main()
{
data_in();
work();
return ;
}
最新文章
- QT下调试基于ros的catkin项目
- osg矩阵变换节点-----平移旋转缩放
- 使用配置文件来配置JDBC连接数据库
- $scope 的生命周期
- curl 模拟登录微信公众平台带验证码
- Linux学习笔记13-用户和组
- GIT简单操作
- 并发容器之ConcurrentSkipListSet
- 使用kendoui对grid指定行变色
- VS2013中C++创建DLL导出class类
- day8 - isinstance--issubclass-异常处理-自定义异常
- Java基于opencv—归一化
- Unity编译时找不到AndroidSDK的问题 | Unable to list target platforms(转载)
- spring的作用是减低耦合,从编译器降低,例如不直接通过new方式 而是通过工厂方式获取对象
- 为iframe添加onclick事件
- JPA问题汇总
- mysql学习之索引
- RESTful记录-RESTful介绍
- 有关在 Word 中撰写博客的帮助
- C#中相关结构的用法及用途