HDU 4666 Hyperspace(曼哈顿距离)
这是HDU第400个题。
#include <cstdio>
#include <cstring>
#include <set>
#include <iostream>
using namespace std;
int p[],qur[][];
int main()
{
int i,j,k,n,m,num;
while(scanf("%d%d",&n,&m)!=EOF)
{
multiset<int> se[];
multiset<int>::iterator it;
for(k = ; k <= n; k ++)
{
scanf("%d",&num);
if(num == )
{
for(i = ; i < m; i ++)
{
scanf("%d",&p[i]);
qur[k][i] = p[i];
}
for(i = ; i < <<m; i ++)
{
int temp = ;
for(j = ; j < m; j ++)
{
if(i&(<<j))
temp += p[j];
else
temp -= p[j];
} se[i].insert(temp);
}
}
else
{
scanf("%d",&num);
for(i = ; i < <<m; i ++)
{
int temp = ;
for(j = ; j < m; j ++)
{
if(i&(<<j))
temp += qur[num][j];
else
temp -= qur[num][j];
}
it = se[i].find(temp);
se[i].erase(it);
}
}
int maxz = ;
for(i = ; i < <<m; i ++)
{
j = (~i)&((<<m)-);
int t1,t2;
it = se[i].end();
it --;
t1 = (*it);
it = se[j].end();
it --;
t2 = (*it);
if(maxz < t1 + t2)
maxz = t1 + t2;
}
printf("%d\n",maxz);
}
}
return ;
}
HDU 4666 Hyperspace(曼哈顿距离)的更多相关文章
- hdu 4666 最大曼哈顿距离
思路:这题我是看了题目后,上百度搜了一下才知道还有求最大曼哈顿距离的方法.直接把代码copy过来,研读一下,知道了代码实现机制,自然就很容易想到用优先队列来维护每种状态下的xi,yi之和的最大值最小值 ...
- hdu 4666:Hyperspace(最远曼哈顿距离 + STL使用)
Hyperspace Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Tota ...
- HDU 4666 Hyperspace (最远曼哈顿距离)
Hyperspace Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Tota ...
- HDU 4666 Hyperspace (2013多校7 1001题 最远曼哈顿距离)
Hyperspace Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Tota ...
- [HDU 4666]Hyperspace[最远曼哈顿距离][STL]
题意: 许多 k 维点, 求这些点之间的最远曼哈顿距离. 并且有 q 次操作, 插入一个点或者删除一个点. 每次操作之后均输出结果. 思路: 用"疑似绝对值"的思想, 维护每种状态 ...
- hdu4666 Hyperspace ——曼哈顿距离
link:http://acm.hdu.edu.cn/showproblem.php?pid=4666 这题学会了怎么处理曼哈顿距离. 比如维数是k,那么每个点有2^k个状态,求出在每个状态下,所有点 ...
- Hdu 4311-Meeting point-1 曼哈顿距离,前缀和
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4311 Meeting point-1 Time Limit: 2000/1000 MS (Java/Oth ...
- hdu 4666 Hyperspace
曼哈顿距离,两个点设为(x1,y1),(x2,y2),其距离为|x1-x2|+|y1-y2| #include <cstdio> #include <set> #include ...
- HDU - 3567 IDA* + 曼哈顿距离 + 康托 [kuangbin带你飞]专题二
这题难度颇大啊,TLE一天了,测试数据组数太多了.双向广度优先搜索不能得到字典序最小的,一直WA. 思路:利用IDA*算法,当前状态到达目标状态的可能最小步数就是曼哈顿距离,用于搜索中的剪枝.下次搜索 ...
随机推荐
- 常州Day4题解
1. 高精度 这题略水,字符串可过,还不加压位等,操作只有BitShift和add/sub,不过编程复杂度有些高.(输出都是二进制我能说些什么...) 2. N皇后问题 (警告! 不是平时你见到的N皇 ...
- linux文件分割(将大的日志文件分割成小的)
linux文件分割(将大的日志文件分割成小的) linux下文件分割可以通过split命令来实现,可以指定按行数分割和安大小分割两种模式.Linux下文件合并可以通过cat命令来实现,非常简单. 在L ...
- sharepoint更新多行文本webparth
前台 <script> function Copy() { var value = document.getElementById("<%=BodyBox.ClientID ...
- 动态设置Div坐标
<style type="text/css"> #main{text-align:center; background-color:#9FF; height:600px ...
- 【leetcode】Implement strStr()
Implement strStr() Implement strStr(). Returns the index of the first occurrence of needle in haysta ...
- spring3 + mybatis + maven:junit测试错误
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component c ...
- python动态获取对象的属性和方法
http://blog.csdn.net/kenkywu/article/details/6822220首先通过一个例子来看一下本文中可能用到的对象和相关概念.01 #coding: UTF- ...
- 在64位的linux上运行32位的程序
1.症状 (1)执行bin文件时提示:No such file or directory (2)ldd bin文件 的输出为: not a dynamic executable (3)file bi ...
- 【转】如何调试bash脚本
本文转自:http://coolshell.cn/articles/1379.html Bash 是Linux操作系统的默认Shell脚本.Shell是用来处理操作系统和用户交互的一个程序.Shell ...
- php中正则表达式的匹配和数据验证总结
正则表达式能匹配复杂的字符串形式,比字符串处理函数功能更加多,只不过执行效率有所降低,但是可以实现非常复杂的匹配,下面总结一下 1.简单的字符串匹配,判断指定字符串是不是在另一个字符串中,和字符串查找 ...