【POJ 1222】 EXTENDED LIGHTS OUT
【题目链接】
http://poj.org/problem?id=1222
【算法】
列出异或方程组,用高斯消元求解即可
【代码】
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <stack>
#include <limits.h>
using namespace std; int i,j,k,T,TC,cnt;
int a[],f[],pos[]; int main()
{ scanf("%d",&T);
while (T--)
{
memset(f,true,sizeof(f));
cnt = ;
memset(a,,sizeof(a));
for (i = ; i <= ; i++) scanf("%d",&a[i]);
for (i = ; i <= ; i++)
{
for (j = ; j <= ; j++)
{
if (i != ) a[(i-)*+j] |= << ((i - ) * + j);
if (i != ) a[(i-)*+j] |= << (i * + j);
if (j != ) a[(i-)*+j] |= << ((i - ) * + j - );
if (j != ) a[(i-)*+j] |= << ((i - ) * + j + );
a[(i-)*+j] |= << ((i - ) * + j);
}
}
for (i = ; i <= ; i++)
{
for (j = i + ; j <= ; j++)
{
if (a[j] > a[i])
swap(a[i],a[j]);
}
if (a[i] == ) break;
for (k = ; k; k--)
{
if (a[i] & ( << k))
{
for (j = ; j <= ; j++)
{
if (i != j && (a[j] & ( << k)))
a[j] ^= a[i];
}
f[k] = false;
pos[k] = i;
break;
}
}
}
printf("PUZZLE #%d\n",++TC);
for (i = ; i <= ; i++)
{
if (f[i]) printf("0 ");
else printf("%d ",a[pos[i]]&);
if (i % == ) printf("\n");
}
} return ; }
【POJ 1222】 EXTENDED LIGHTS OUT的更多相关文章
- POJ - 1222: EXTENDED LIGHTS OUT (开关问题-高斯消元)
pro:给定5*6的灯的状态,如果我们按下一个灯的开关,它和周围4个都会改变状态.求一种合法状态,使得终状态全为关闭: sol:模2意义下的高斯消元. 终于自己手打了一个初级板子. #include& ...
- bzoj 2295: 【POJ Challenge】我爱你啊
2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...
- 【链表】BZOJ 2288: 【POJ Challenge】生日礼物
2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 382 Solved: 111[Submit][S ...
- BZOJ2288: 【POJ Challenge】生日礼物
2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 284 Solved: 82[Submit][St ...
- BZOJ2293: 【POJ Challenge】吉他英雄
2293: [POJ Challenge]吉他英雄 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 80 Solved: 59[Submit][Stat ...
- BZOJ2287: 【POJ Challenge】消失之物
2287: [POJ Challenge]消失之物 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 254 Solved: 140[Submit][S ...
- BZOJ2295: 【POJ Challenge】我爱你啊
2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 126 Solved: 90[Submit][Sta ...
- BZOJ2296: 【POJ Challenge】随机种子
2296: [POJ Challenge]随机种子 Time Limit: 1 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 114 Solv ...
- BZOJ2292: 【POJ Challenge 】永远挑战
2292: [POJ Challenge ]永远挑战 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 513 Solved: 201[Submit][ ...
随机推荐
- ★Java语法(五)——————————三元运算符
package 课上练习; public class 三元运算符 { //用法: 数据类型 变量 = 布尔表达式? 条件满足设置内容:条件不满足设置内容 : public static void ma ...
- C语言笔记(二)
注释 编译器会用空格代替代码中原来的注释,并先于预处理指令执行/*…*/ 这种形式的注释不能嵌套只要斜杠(/)和星号(*)之间没有空格,都会被当作注释的开始.例如这样:y = x/*p; \ 是一个接 ...
- WebGL绘制三角形
本文程序实现绘制一个三角形的任务,如下图. 整个程序包含两个文件,分别是: 1. HelloTriangle.html <!DOCTYPE HTML PUBLIC "-//W3C//D ...
- Shiro Shiro Web Support and EnvironmentLoaderListener
Shiro Shiro Web Support 主要参考: http://shiro.apache.org/web.html 还有涛哥的 作为资源控制访问的事情,主要使用在网络后台方面,所以了解了本地 ...
- ext4的一些特性
delalloc介绍 delalloc是ext4下的一个新特性,延迟分配技术Delay Allocation. 实现原理为: Buffer Write时数据会被保存到page cache中,但是系统并 ...
- 通过JDBC取Oracle数据库的时间字段时,时间丢失,只剩日期
通过JDBC连接Oracle数据库,在查询的时候发现时间字段取出来值后只剩下了日期,时间消失了.查资料发现跟Oracle jdbc驱动版本有关,这里先贴出解决方案: 修改数据库的连接方式: try { ...
- vue 对图片进行拖拽到另一个位置
1.拖动元素代码: 使用html5原生拖拽属性,在需要拖拽的图片中添加draggable="true"属性,并使用v-on添加拖动事件 2.被放置的区域事件代码: 使用html5原 ...
- C#学习笔记_01_基础内容
01_基础内容 进(位)制 十进制:逢10进1,数字由0-9组成: 二进制:逢2进1,数字由0-1组成: 八进制:逢8进1,数字由0-7组成: 十六进制:逢16进1,数字由0-9和a-f组成: 进制转 ...
- VS2015 C++ 获取 Edit Control 控件的文本内容,以及把获取到的CString类型的内容转换为 int 型
UpdateData(true); //读取编辑框内容,只要建立好控件变量后调用这个函数使能,系统就会自动把内容存在变量里 //这里我给 Edit Control 控件创建了一个CString类型.V ...
- 域名和ip、端口的关系
背景:新建一个项目,属于RPC服务,调用时需要ip+端口. 在工单系统里走流程,强制填写域名.之前也操作过,感觉域名不重要.我本来需要填写ip+端口,你给整个域名,那我端口往哪写?(一直以为域名=ip ...