hdu-4666 Hyperspace
来源:互联网 发布:上海淘宝拍照基地 编辑:程序博客网 时间:2024/06/09 18:43
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=4666
求k维的最远曼哈顿距离
没有初始化 最后wa了...
#include <cstdio>#include <cstring>#include <iostream>#include <queue>#include <functional>#define MAXSIZE 60000+3#define MAXTYPE ((1<<5)+3)#define INF ((1<<31)-1)using namespace std;struct node1{ friend bool operator<(node1 n1, node1 n2) { return n1.value < n2.value; } int value, point;};struct node2{ friend bool operator< (node2 n1, node2 n2) { return n1.value > n2.value; } int value, point;};int n, dem, flag, point[6], del, ans;bool exist[MAXSIZE];int main(){ int i, j, k, tmp, t, s; while (scanf("%d %d\n", &n, &dem) != EOF) { ans = 0; priority_queue<node1> maxx[MAXTYPE]; // 没有初始化 wa了 好囧 priority_queue<node2> minx[MAXTYPE]; //开的是全局变量... 弄进来就好了 memset(exist, 0, sizeof(exist)); tmp = 1<<dem; for (i = 1; i <= n; i++) { scanf("%d", &flag); if (!flag) { exist[i] = true; for (j = 1; j <= dem; j++) scanf("%d", &point[j]); for (j = 0; j < tmp; j++) { t = j; s = 0; for(k = 1; k <= dem; k++) { if(t & 1) s += point[k]; else s-= point[k]; t >>= 1; } node1 ttt; ttt.value = s; ttt.point = i; node2 qqq; qqq.value = s; qqq.point = i; maxx[j].push(ttt); minx[j].push(qqq); } } else { scanf("%d", &del); exist[del] = false; for (j = 0; j < tmp; j++) { while (!exist[maxx[j].top().point]) maxx[j].pop(); while (!exist[minx[j].top().point]) minx[j].pop(); } } ans = maxx[0].top().value-minx[0].top().value; for (j = 1; j < tmp; j++) { if (ans < maxx[j].top().value-minx[j].top().value) ans = maxx[j].top().value-minx[j].top().value; } printf("%d\n", ans); } } return 0;}
- HDU 4666 Hyperspace
- hdu-4666 Hyperspace
- hdu 4666 Hyperspace
- HDU 4666 Hyperspace
- hdu 4666 Hyperspace
- HDU 4666 Hyperspace
- hdu 4666Hyperspace
- HDU 4666 Hyperspace
- HDU 4666 Hyperspace
- HDU——4666 Hyperspace
- HDU 4666 Hyperspace 解题报告
- Hdu-4666 Hyperspace(曼哈顿距离)
- hdu 4666 Hyperspace 多校第七场
- hdu-4666-Hyperspace-最长曼哈顿距离
- [HDU 4666]Hyperspace[最远曼哈顿距离][STL]
- hdu 4666 Hyperspace (曼哈顿距离+set )
- [HDU 4666]Hyperspace[最远曼哈顿距离][STL]
- HDU 4666 Hyperspace(最长曼哈顿距离)
- spidermonkey学习
- 第十一天(Using Views in Your Applications)
- JavaScript 引擎 SpiderMonkey
- 关于Delphi中TRttiContext.FindType失效的问题
- 八款开源 Android 游戏引擎
- hdu-4666 Hyperspace
- 字符串权重
- [leetcode刷题系列]Word Search
- SQL怎样建立全文索引
- 30s清除电脑中垃圾
- memcache经典介绍
- JSAPI Cookbook
- oracle客户端卸载:
- Linux ruid、euid和suid区别