【题目链接】

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. android黑科技系列——Apk混淆成中文语言代码

    一.前言 最近想爆破一个app,没有加壳,简单的使用Jadx打开查看源码,结果把我逗乐了,代码中既然都是中文,而且是一些比较奇葩的中文字句,如图所示: 瞬间感觉懵逼了,这app真会玩,我们知道因为Ja ...

  2. 使用 gradle 在编译时动态设置 Android resValue / BuildConfig / Manifes中<meta-data>变量的值

    转载请说明来源: http://www.cnblogs.com/lizhilin2016/p/7390079.html 最近lz 在开始做一个新的Demo, 在项目中集成了bugly用于收集项目中的崩 ...

  3. php数据库批量删除

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...

  4. 2013款MacBook Air装Windows7单系统

    经过两天的摸索,查找无数资料终于把2013款的MacBook Air装上了WIN 7,虽然网上有很多的资料但是都不是我想要的,第一个我的是2013款的MacBook Air,跟原来2012 11款Ma ...

  5. Vs2010删除空白行

    在copy了别人的代码之后,出现了大量的空白行,批量删除空白行方法为: 查找内容:^:b*$\n 替换为: 查找范围:当前文档 使用:正则表达式

  6. Android 链接 手机有关问题及解决方案

    我出现的问题: 这是我百度的解决方案:

  7. 读书笔记「Python编程:从入门到实践」_4.操作列表

    4.1 遍历整个列表   4.1.1 深入地研究循环   4.1.2 在for循环中执行更多的操作   4.1.3 在for循环结束后执行一些操作  例 magicians = ['alice', ' ...

  8. springMvc学习地址新

    http://www.admin10000.com/document/6436.html 一.SpringMVC基础入门,创建一个HelloWorld程序 1.首先,导入SpringMVC需要的jar ...

  9. Emoji表情处理工具类

    import java.util.regex.Matcher; import java.util.regex.Pattern; public class EmojiToString { /** * 将 ...

  10. PAT_A1122#Hamiltonian Cycle

    Source: PAT A1122 Hamiltonian Cycle (25 分) Description: The "Hamilton cycle problem" is to ...