【题目链接】

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. JavaScipt30(第三个案例)(主要知识点:css变量)

    承接上文 https://www.cnblogs.com/wangxi01/p/10641210.html,下面是第三个案例: 附上项目链接: https://github.com/wesbos/Ja ...

  2. The following packages have unmet dependencies:

    root@ubuntu:~# apt-get install open-iscsiReading package lists... DoneBuilding dependency treeReadin ...

  3. 在做导入一个excel文件的时候,数据有空值的时候

    StringUtil.isNotEmpty(i.getFname()),用这个方法可以解决 java string 去除前后两端的空格和空字符使用.trim()

  4. mysql的密码管理、mysql初始密码查找、密码修改、mysql登录

    1.查询mysql的初始密码: 初始密码密码是随机产生的,每台机器产生的都不一样的 grep 'temporary password' /var/log/mysqld.log 或者 cat /var/ ...

  5. Cmake的介绍和使用 Cmake实践

    Cmake的介绍和使用 Cmake实践http://www.cppblog.com/Roger/archive/2011/11/17/160368.html

  6. Codeforces Educational Codeforces Round 17 Problem.A kth-divisor (暴力+stl)

    You are given two integers n and k. Find k-th smallest divisor of n, or report that it doesn't exist ...

  7. 【18】AngularJS 包含

    AngularJS 包含 在 AngularJS 中,你可以在 HTML 中包含 HTML 文件. 在 HTML 中包含 HTML 文件 在 HTML 中,目前还不支持包含 HTML 文件的功能. 服 ...

  8. Android BottomSheet:以选取图片为例(2)

     Android BottomSheet:以选取图片为例(2) 附录文章5简单介绍了常见的分享面板在BottomSheet中的具体应用.本文再以常见的选取图片为例写一个例子. 布局文件: < ...

  9. HDU 1176 DP

    题目大意: 在0~10这11个点上面接饼 , 每秒最多往左或往移动一格,或者保持原地不动 令dp[i][j]表示在第 i 秒在 第 j 个点上最多能得到的饼的数量 dp[i][j] = max(dp[ ...

  10. noip模拟赛 寻宝之后

    题目背景 还记得NOIP2011的寻宝吗?6年之后,小明带着他的妹子小芳,再次走上了寻宝的道路. 然而这次他们寻宝回来之后,小明被困在了一个迷宫中. 题目描述 迷宫是一个n*m的字符矩阵. 小明在这个 ...