BZOJ1923: [Sdoi2010]外星千足虫
高斯消元求解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; }
BZOJ1923: [Sdoi2010]外星千足虫的更多相关文章
- bzoj千题计划188:bzoj1923: [Sdoi2010]外星千足虫 (高斯—若尔当消元法解异或方程组)
http://www.lydsy.com/JudgeOnline/problem.php?id=1923 #include<cstdio> #include<cstring> ...
- 【题解】 bzoj1923: [Sdoi2010]外星千足虫 (线性基/高斯消元)
bzoj1923,戳我戳我 Solution: 这个高斯消元/线性基很好看出来,主要是判断在第K 次统计结束后就可以确定唯一解的地方和\(bitset\)的骚操作 (我用的线性基)判断位置,我们可以每 ...
- bzoj1923[Sdoi2010]外星千足虫(高斯消元)
Description Input 第一行是两个正整数 N, M. 接下来 M行,按顺序给出 Charles 这M次使用“点足机”的统计结果.每行 包含一个“01”串和一个数字,用一个空格隔开.“01 ...
- BZOJ1923:[SDOI2010]外星千足虫(高斯消元)
Description Input 第一行是两个正整数 N, M. 接下来 M行,按顺序给出 Charles 这M次使用“点足机”的统计结果.每行 包含一个“01”串和一个数字,用一个空格隔开.“01 ...
- BZOJ1923 [Sdoi2010]外星千足虫 【高斯消元】
题目 输入格式 第一行是两个正整数 N, M. 接下来 M行,按顺序给出 Charles 这M次使用"点足机"的统计结果.每行 包含一个"01"串和一个数字,用 ...
- 【高斯消元】【异或方程组】【bitset】bzoj1923 [Sdoi2010]外星千足虫
Xor方程组解的个数判定: ——莫涛<高斯消元解Xor方程组> 使用方程个数判定:消去第i个未知数时,都会记录距第i个方程最近的第i位系数不为0の方程是谁,这个的max就是使用方程个数. ...
- 【BZOJ1923】[Sdoi2010]外星千足虫 高斯消元
[BZOJ1923][Sdoi2010]外星千足虫 Description Input 第一行是两个正整数 N, M. 接下来 M行,按顺序给出 Charles 这M次使用“点足机”的统计结果.每行 ...
- 【BZOJ-1923】外星千足虫 高斯消元 + xor方程组
1923: [Sdoi2010]外星千足虫 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 766 Solved: 485[Submit][Status ...
- bzoj 1923 [Sdoi2010]外星千足虫(高斯消元+bitset)
1923: [Sdoi2010]外星千足虫 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 634 Solved: 397[Submit][Status ...
随机推荐
- Foundation框架下的常用类:NSNumber、NSDate、NSCalendar、NSDateFormatter、NSNull、NSKeyedArchiver
========================== Foundation框架下的常用类 ========================== 一.[NSNumber] [注]像int.float.c ...
- Git本地服务器搭建及使用详解
Git本地服务器搭建及使用 Git是一款免费.开源的分布式版本控制系统.众所周知的Github便是基于Git的开源代码库以及版本控制系统,由于其远程托管服务仅对开源免费,所以搭建本地Git服务器也是个 ...
- sql面试题(学生表_课程表_成绩表_教师表)
原帖链接:http://bbs.csdn.net/topics/280002741 表架构 Student(S#,Sname,Sage,Ssex) 学生表 Course(C#,Cname,T#) 课程 ...
- android r.styleable是什么或报错
r.styleable 是自定义控件 自定义控件写好的后,需要在res-value-attrs.xml中定义,如: <declare-styleable name="SlidingMe ...
- 【转】(超详细)jsp与servlet之间页面跳转及参数传递实例
初步学习JavaEE,对其中jsp与Servlet之间的传值没弄清楚,查看网上资料,发现一篇超详细的文章,收获大大,特此记录下来.具体链接:http://blog.csdn.net/ssy_shand ...
- Vue.js的入门
介绍 vue.js 是一个客户端js库,可以用来开发单页应用.为了一个项目的选型,我前前后后的看了angular.react.vuejs ,对前两者是佩服,对后者是爱.因为它简洁干净利索,并且还有高大 ...
- jQuery插件开发精品教程,让你的jQuery提升一个台阶
要说jQuery 最成功的地方,我认为是它的可扩展性吸引了众多开发者为其开发插件,从而建立起了一个生态系统.这好比大公司们争相做平台一样,得平台者得天下.苹果,微软,谷歌等巨头,都有各自的平台及生态圈 ...
- [LeetCode] Linked List Cycle 单链表中的环
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using ex ...
- [LeetCode] Word Break 拆分词句
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separa ...
- [LeetCode] Pow(x, n) 求x的n次方
Implement pow(x, n). 这道题让我们求x的n次方,如果我们只是简单的用个for循环让x乘以自己n次的话,未免也把LeetCode上的想的太简单了,一句话形容图样图森破啊.OJ因超时无 ...