【题目链接】

http://poj.org/problem?id=2965

【算法】

位运算

【代码】

#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;
const int MASK = ; int i,j,tmp,s,mn,p,sum;
int a[];
char c; inline int calc(int x,int y)
{
int pos = * x + y - ;
int ret = ;
int tmp = pos;
while (tmp < * x)
{
ret |= ( << tmp);
tmp++;
}
tmp = pos;
while (tmp >= * x - )
{
ret |= ( << tmp);
tmp--;
}
tmp = pos;
while (tmp < )
{
ret |= ( << tmp);
tmp += ;
}
tmp = pos;
while (tmp >= y - )
{
ret |= ( << tmp);
tmp -= ;
}
return ret;
} int main()
{ for (i = ; i <= ; i++)
{
for (j = ; j <= ; j++)
{
a[*i+j-] = calc(i,j);
}
}
for (i = ; i < ; i++)
{
scanf("%c",&c);
if (c == '-') s |= ( << i);
if (i % == ) scanf("%c",&c);
}
mn = MASK;
for (i = ; i <= MASK; i++)
{
tmp = s; sum = ;
for (j = ; j < ; j++)
{
if (i & ( << j))
{
sum++;
tmp ^= a[j];
}
}
if (tmp == MASK && sum < mn)
{
mn = sum;
p = i;
}
}
printf("%d\n",mn);
for (i = ; i < ; i++)
{
if (p & ( << i))
printf("%d %d\n",i/+,i%+);
} return ; }

【POJ 2965】 The Pilots Brothers' refrigerator的更多相关文章

  1. POJ 2965:The Pilots Brothers&#39; refrigerator

    id=2965">The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total S ...

  2. 【POJ2965】The Pilots Brothers' refrigerator

    题目传送门 本题知识点:深度优先搜索 + 暴力枚举 + 回溯 + 栈 如果对以上知识点还不熟悉的同学建议先做做 POJ1753 (本题是1753的提高版)(附 POJ1753博客) 以下默认您已ACP ...

  3. POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286 ...

  4. 枚举 POJ 2965 The Pilots Brothers' refrigerator

    题目地址:http://poj.org/problem?id=2965 /* 题意:4*4的矩形,改变任意点,把所有'+'变成'-',,每一次同行同列的都会反转,求最小步数,并打印方案 DFS:把'+ ...

  5. poj 2965 The Pilots Brothers' refrigerator (dfs)

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 17450 ...

  6. POJ 2965 The Pilots Brothers' refrigerator 暴力 难度:1

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16868 ...

  7. POJ 2965 The Pilots Brothers' refrigerator 位运算枚举

      The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 151 ...

  8. POJ 2965 The Pilots Brothers' refrigerator (DFS)

    The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15136 ...

  9. POJ:2695-The Pilots Brothers' refrigerator

    题目链接:http://poj.org/problem?id=2965 The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limi ...

随机推荐

  1. eclipse配置Tomcat服务器server locations的方法

    最近放弃了使用Myeclipse,转而使用eclipse作为开发工具,确实Myeclipse集成了太多东西,使得开发人员的配置越来越少,这不是个好事,使用eclipse后,有些地方就得自己去配置,比如 ...

  2. N18_二叉树的镜像

    题目描述 操作给定的二叉树,将其变换为源二叉树的镜像. 输入描述: 二叉树的镜像定义:源二叉树 8 / \ 6 10 / \ / \ 5 7 9 11 镜像二叉树 8 / \ 10 6 / \ / \ ...

  3. ArrayAccess(数组式访问)

    实现该接口后,可以像访问数组一样访问对象. 接口摘要: ArrayAccess { abstract public boolean offsetExists ( mixed $offset ) abs ...

  4. Spring学习开发之路——使用JavaBean代替EJB

    Spring框架是由于软件开发的复杂性而创建的.Spring使用的是基本的JavaBean来完成以前只可能由EJB完成的事情.然而,Spring的用途不仅仅限于服务器端的开发.从简单性.可测试性和松耦 ...

  5. HDU - 5952 Counting Cliques(dfs搜索)

    题目: A clique is a complete graph, in which there is an edge between every pair of the vertices. Give ...

  6. 爬虫之pyquery库

    官方文档:https://pyquery.readthedocs.io/en/latest/ PyQuery是一个强大又灵活的网页解析库.如果你觉得正则写起来太麻烦.BeautifulSoup语法太难 ...

  7. vue中axios设置

    //设置默认全局baseURL axios.defaults.baseURL=process.env.BASE_API; //设置默认全局携带浏览器cookie axios.defaults.with ...

  8. hdu 1874 dijkstra 队列实现 比数组高效特别在稀疏图

    参考  http://blog.csdn.net/zhuyingqingfen/article/details/6370561 刘汝佳白皮书 #include<stdio.h> #incl ...

  9. ORA-12541:TNS:无监听程序

    安装oracle以后,sql plus可以正常登陆,pl/sql登陆时报错ORA-12541:TNS:无监听程序,解决方案如下: http://blog.csdn.net/hao134838/arti ...

  10. 在DJANGO中如何定义get_absolute_url

    有好几种办法呢... 书上有说: 常见的: class Image(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, ...