首页 技术 正文
技术 2022年11月19日
0 收藏 831 点赞 2,335 浏览 1231 个字

传送门

高斯消元求解Xor方程。

这个方程很容易换成xor的方程。然后用高斯消元搞就行了。

bitset实现这个非常方便。

//BZOJ 1923//by Cydiater//2016.11.3#include <iostream>#include <queue>#include <map>#include <ctime>#include <cmath>#include <cstring>#include <string>#include <algorithm>#include <cstdio>#include <cstdlib>#include <iomanip>#include <set>#include <bitset>using namespace std;#define up(i,j,n)for(int i=j;i<=n;i++)#define down(i,j,n)for(int i=j;i>=n;i--)#define cmax(a,b) a=max(a,b)#define cmin(a,b)a=min(a,b)#define ll long long#define bs bitset<1005>const int MAXN=2e3+5;const int oo=0x3f3f3f3f;inline int read(){char ch=getchar();int x=0,f=1;while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}int N,MM,ans=0;bs M[MAXN];char s[MAXN];namespace solution{void init(){N=read();MM=read();up(i,1,MM){scanf("%s",s+1);up(j,1,N)M[i][j]=s[j]-'0';scanf("%s",s+1);M[i][N+1]=s[1]-'0';}}void Guass(){up(i,1,N){up(j,i,MM)if(M[j][i]){cmax(ans,j);if(i!=j)swap(M[i],M[j]);break;}if(!M[i][i]){ans=-1;break;}up(j,1,MM)if(M[j][i]&&j!=i)M[j]^=M[i];}}void slove(){Guass();if(ans==-1)puts("Cannot Determine");else{cout<<ans<<endl;up(i,1,N)if(M[i][N+1])puts("?y7M#");else puts("Earth");}}}int main(){//freopen("input.in","r",stdin);using namespace solution;init();slove();return 0;}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,040
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,526
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,373
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,154
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,787
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,869