【HDU】3255 求长方体并的体积
来源:互联网 发布:windows 7 sp2 编辑:程序博客网 时间:2024/04/28 18:06
#define _CRT_SECURE_NO_WARNINGS#include<algorithm>#include<iostream>#include<cstdio>#include<cstring>using namespace std;#define MAX 100003#define ls rt<<1#define rs ls|1#define m (l+r)>>1int col[MAX << 2];long long sum2[MAX << 2];int value[4];int posx[MAX];struct pos{int l, r, h, s, x;pos(){}pos(int _l, int _r, int _h, int _s, int _x){l = _l;r = _r;h = _h;s = _s;x = _x;}bool operator<(pos b){return h < b.h;}}p[MAX],temp[MAX];void uprt(int l, int r, int rt){if (col[rt]){sum2[rt] = posx[r + 1] - posx[l];return;}if (l == r)sum2[rt] = 0;elsesum2[rt] = sum2[ls] + sum2[rs];}void updata(int L, int R, int c,int l, int r, int rt){if (L <= l&&r <= R){col[rt] += c;uprt(l, r, rt);return;}int mid = m;if (L <= mid)updata(L, R, c,l, mid, ls);if (mid < R)updata(L, R, c, mid + 1, r, rs);uprt(l, r, rt);}int main(){int t;cin >> t;int icase = 1;while (t--){int n, k;scanf("%d%d", &n, &k);for (int i = 1; i <= k; i++)scanf("%d", &value[i]);int x1, x2, y1, y2, x;int cnt = 0;for (int i = 0; i < n; i++){scanf("%d%d%d%d%d", &x1, &y1, &x2, &y2, &x);posx[cnt] = x1;p[cnt++] = pos(x1, x2, y1, 1, value[x]);posx[cnt] = x2;p[cnt++] = pos(x1, x2, y2, -1, value[x]);}sort(p, p + cnt);sort(posx, posx + cnt);int cnt2 = unique(posx, posx + cnt) - posx;sort(value + 1, value + 1 + k);long long ans = 0;for (int j = 1; j <=k; j++){int cnt3 = 0;for (int i = 0; i < cnt;i++)if (p[i].x > value[j-1])temp[cnt3++] = p[i];memset(col, 0, sizeof(col));memset(sum2, 0, sizeof(sum2));for (int i = 0; i < cnt3- 1; i++){int curl = lower_bound(posx, posx + cnt2, temp[i].l) - posx;int curr = lower_bound(posx, posx + cnt2, temp[i].r) - posx - 1;updata(curl, curr, temp[i].s, 0, cnt2 - 1, 1);ans += sum2[1] * (temp[i + 1].h - temp[i].h)*(value[j]-value[j-1]);}}printf("Case %d: %lld\n", icase++, ans);}}
0 0
- 【HDU】3255 求长方体并的体积
- 【HDU 3642 求长方体的体积并
- hdu 3255 Farming(线段树求长方体体积并)
- poj 2944 求长方体的体积并
- hdu 3642 求长方体的体积交
- 求三个长方体的体积
- 求一长方体的体积和表面积
- 求长方体的体积C++代码
- 求长方体的体积和表面积
- 求五个长方体的体积表面积
- 类的派生实现求长方体体积
- 求长方体体积,表面积
- 第三周实验报告4求长方体的体积表面积
- 第八周项目2 求长方体的表面积和体积
- HDU 3642 Get The Treasury (线段树扫描线进阶--求长方体重叠3次或以上的体积)
- hdu 3642 求长方体的体积交 (线段树 +离散化+扫描线)(重点!模板!)
- Hdu 3642 Get The Treasury(长方体的体积交)
- [线段树] hdu 3255 Farming#求体积并
- 译文-Android的MVP模式开发系列文章(2)
- 最受欢迎的开源项目
- python 可连接多个客户端的服务器 fork版
- Sicily 12259. Message Relay
- day10-jsp&ELの代码学习(EL)
- 【HDU】3255 求长方体并的体积
- Sicily 12747. Breed Proximity
- 杭电 HDU 1029 Ignatius and the Princess IV
- noi2012美食节
- Android:真机调试,不显示logcat的解决方案
- Git生成patch和合入patch
- Sicily 2505. 糖果传递
- LeetCode 119 Pascal's Triangle II
- Sicily 8842. Mirko's Exam