【题目链接】

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. C# 多线程系列(一)

    线程是怎样工作的 1.多线程由一个线程调度器来进行内部管理,一个功能是CLR常常委托给操做系统. 一个线程调度器确保所有激活的线程在执行期间被合适的分配,等待或者阻塞的线程(比如,一个独占锁或者等待用 ...

  2. android黑科技系列——Xposed框架实现拦截系统方法详解

    一.前言 关于Xposed框架相信大家应该不陌生了,他是Android中Hook技术的一个著名的框架,还有一个框架是CydiaSubstrate,但是这个框架是收费的,而且个人觉得不怎么好用,而Xpo ...

  3. view在使用shape属性加圆角的同时,用代码修改其他background属性(例如颜色)不生效

    项目中一个TextView控件设置了shape属性,给其加了圆角,如下: houlder.mtxtGovernmentType.setBackgroundResource(R.drawable.tv_ ...

  4. c#如何用代码开启cmd指定命令(如:运行一个手机adb shell命令)

    else if (this.Mode == TravelMode.AutoRecodeMode) { DateTime StartDate = DateTime.Now; string args = ...

  5. 个人作业—Alpha测试

    这个作业属于哪个课程 https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass1/homework/3338 这个作业要求在哪里 htt ...

  6. BZOJ 1577: [Usaco2009 Feb]庙会捷运Fair Shuttle 线段树 + 贪心

    escription 公交车一共经过N(1<=N<=20000)个站点,从站点1一直驶到站点N.K(1<=K<=50000)群奶牛希望搭乘这辆公交车.第i群牛一共有Mi(1&l ...

  7. Django MVC与MTV概念 Ajax、分页实现

     MVC与MTV概念 MTV与MVC(了解)        MTV模型(django):            M:模型层(models.py)            T:templates      ...

  8. Day 23 类的继承,派生,组合,菱形继承,多态与多态性

    类的继承 继承是一种新建类的方式,新建的类称为子类,被继承的类称为父类 继承的特性是:子类会遗传父类的属性 继承是类与类之间的关系 为什么用继承 使用继承可以减少代码的冗余 对象的继承 python中 ...

  9. 关于计算文字显示占用画面大小(System.Drawing.Graphics.MeasureString)

    最近遇到了一个需要手动为显示文字换行的场合,网上转了一圈,最后形成了下面的代码: var font = new Font("微软雅黑", 9F); - DETAIL_BASE_IN ...

  10. eas之设置编辑界面分录的某一列不可编辑

    KDTEntrys.getColumn(“xx”).getStayAttributes().setlokced(true);