【题目链接】

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的更多相关文章

  1. POJ - 1222: EXTENDED LIGHTS OUT (开关问题-高斯消元)

    pro:给定5*6的灯的状态,如果我们按下一个灯的开关,它和周围4个都会改变状态.求一种合法状态,使得终状态全为关闭: sol:模2意义下的高斯消元. 终于自己手打了一个初级板子. #include& ...

  2. bzoj 2295: 【POJ Challenge】我爱你啊

    2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec  Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...

  3. 【链表】BZOJ 2288: 【POJ Challenge】生日礼物

    2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 382  Solved: 111[Submit][S ...

  4. BZOJ2288: 【POJ Challenge】生日礼物

    2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 284  Solved: 82[Submit][St ...

  5. BZOJ2293: 【POJ Challenge】吉他英雄

    2293: [POJ Challenge]吉他英雄 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 80  Solved: 59[Submit][Stat ...

  6. BZOJ2287: 【POJ Challenge】消失之物

    2287: [POJ Challenge]消失之物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 254  Solved: 140[Submit][S ...

  7. BZOJ2295: 【POJ Challenge】我爱你啊

    2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 126  Solved: 90[Submit][Sta ...

  8. BZOJ2296: 【POJ Challenge】随机种子

    2296: [POJ Challenge]随机种子 Time Limit: 1 Sec  Memory Limit: 128 MBSec  Special JudgeSubmit: 114  Solv ...

  9. BZOJ2292: 【POJ Challenge 】永远挑战

    2292: [POJ Challenge ]永远挑战 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 513  Solved: 201[Submit][ ...

随机推荐

  1. js 事件冒泡、事件捕获、stopPropagation、preventDefault

    转自:http://www.jb51.net/article/42492.htm (1)冒泡型事件:事件按照从最特定的事件目标到最不特定的事件目标(document对象)的顺序触发. IE 5.5: ...

  2. 三维重建:SFM中BA的并行化

    1. BA在重建中的作用 借鉴于运动中重建的方法,BA引入SLAM过程,而传统的滤波方法引入BA是跟随闭环检测出现. 1.1 BA在滤波方法中的嵌入 PTAM 1.2 BA在闭环检测之后的应用 在三维 ...

  3. 【C++】四种排序算法的时间比较

    四种排序算法的时间比较 [注]clock函数对输入(用户输入)元素N排序的计时 #include<iostream> #include<time.h> using namesp ...

  4. C# MVC 获得程序运行路径

    string filePath = System.Web.HttpContext.Current.Request.MapPath("~/Upload"); //由虚拟路径指定的服务 ...

  5. 从读写分离到 CQRS,张大胖是如何解决性能问题的?

    转自:https://mp.weixin.qq.com/s/rpiYZkxiLKa77OFw8XaBwA 不堪重负的数据库 张大胖公司的数据库已经不堪重负了. 这个系统最早是两个实习生写的, 按照最初 ...

  6. 拷贝构造和拷贝赋值、静态成员(static)、成员指针、操作符重载(day06)

    十七 拷贝构造和拷贝赋值 浅拷贝和深拷贝 )如果一个类中包含指针形式的成员变量,缺省的拷贝构造函数只是复制了指针变量的本身,而没有复制指针所指向的内容,这种拷贝方式称为浅拷贝. )浅拷贝将导致不同对象 ...

  7. onunload与onbeforeunload事件解析 标签: 浏览器 2017-04-10 09:46 45人阅读 评论(0)

    注:只测试了chrome和IE浏览器的表现情况 onunload事件 //JS Document window.onunload = onunload_message; function onunlo ...

  8. CSS学习笔记之CSS3新特性

    目录 1.边框 2.背景 3.文本 4.字体 5.转换 6.过渡 7.动画 8.多列 9.自定义尺寸 CSS 用于控制网页的样式和布局,而 CSS3 是最新的 CSS 标准,这篇文章将着重介绍 CSS ...

  9. 23.partial update

    主要知识点 1.什么是partial update(部分修改) 2.partial update的语法 3.在es内部partial update的实现过程 4.partial update优点 一. ...

  10. javascript基础扫盲

    JavaScript基础扫盲 null和undefined 非十进制的表示方法 强制类型转换 运算 null和undefined null是一个是非来表示一个空对象的,故 typeof 的返回值是ob ...