【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][ ...
随机推荐
- Redis配置文件各项参数说明及性能调优
Redis配置文件参数说明: 1. Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程 daemonize no 2. 当Redis以守护进程方式运行时,Redis默 ...
- Leetcode0100--Same Tree 相同树
[转载请注明]http://www.cnblogs.com/igoslly/p/8707664.html 来看一下题目: Given two binary trees, write a functio ...
- JDK自带工具
工具名称 描述 appletviewer.exe 用于运行并浏览applet小程序. apt.exe 注解处理工具(Annotation Processing Tool),主要用于注解处理. extc ...
- selenium选错弹出层的下拉框
要先选中这个弹出层的form元素,再找下拉框 public void downSelectBox(){ driver.get("https://www.imooc.com/user/setp ...
- (转)Bootstrap 之 Metronic 模板的学习之路 - (2)源码分析之 head 部分
https://segmentfault.com/a/1190000006684122 下面,我们找个目录里面想对较小的文件来分析一下源码结构,我们可以看到,page_general_help.htm ...
- 预备篇 I :范畴与函子
拓扑是研究几何图形或空间在连续改变形状后还能保持不变的一些性质的一个学科.它只考虑物体间的位置关系而不考虑它们的形状和大小. 拓扑是集合上的一种结构. 拓扑英文名是Topology,直译是地志学,最早 ...
- js 响应事件
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- phpStudy 升级 MySQL版本
1:停止phpStudy ,Mysql 服务;删除Mysql 文件夹 替换为新版本的Mysql 2:复制一份 my-default.ini,改名 my.ini ,打开,在最后面加上: basedir= ...
- OSI参考模型(转)
一.OSI参考模型 自下而上:物理层(物理介质,比特流).数据链路层(网卡.交换机).网络层(IP协议).传输层(TCP/UDP协议).会话层(创建/建立/断开连接).表示层(翻译,编码,压缩,加密) ...
- 记录:通过SSH远程连接Ubuntu
一.安装openssh服务器 $ sudo apt-get install openssh-server 二.启动ssh服务 安装完成后,启动服务: $ sudo /etc/init.d/ssh st ...