UVALive 7261 Xiongnu's Land (扫描线)】的更多相关文章

Wei Qing (died 106 BC) was a military general of the Western Han dynasty whose campaigns against the Xiongnu earned him great acclaim. He was a relative of Emperor Wu because he was the younger half-brother of Empress Wei Zifu (Emperor Wu’s wife) and…
思路: 先二分下界,再二分上届. #include <bits/stdc++.h> using namespace std; #define MP make_pair #define PB push_back typedef long long LL; typedef pair<int,int> PII; ; const double pi=acos(-1.0); ; ; struct node { int x,y,w,h; node(){} node(int a,int b,in…
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5273 Wei Qing (died BC) was a military general of the Western Han dynasty whose campaigns against the Xiongnu earned him great acclaim.…
Wei Qing (died 106 BC) was a military general of the Western Han dynasty whose campaigns against the Xiongnu earned him great acclaim. He was a relative of Emperor Wu because he was the younger half-brother of Empress Wei Zifu (Emperor Wu’s wife) and…
拿到了icpc北京站的参赛名额 感谢亮哥~ 虽然是地狱之战 但也要全力以赴! 题意: 有一片沙漠 n片绿洲 让你用一条线分成两部分 左≥右 而且分割线要尽量靠右 问线的位置 思路: 网上说可以二分 没太看懂…… 还有一种思路就是线性扫描 将二维的图化成一维的线 然后从头扫一遍 遇到左≥sum/2时试探着向右继续扫 最后输出答案 不知道为啥hihocoder能过uvalive死活就是过不去…… #include<stdio.h> #include<iostream> #include…
题目 传送门:QWQ 分析 扫描线搞一搞. 按左端点排序,左端点相同时按右端点排序. 如果是左端点就$ cnt++ $,否则$ cnt-- $ 统计一下$ Max $就行了 代码 #include <bits/stdc++.h> using namespace std; void update(int x,int a,int w,double& L,double& R){ if(a==0){ if(x<=0||x>=w) R=L-1; } else if(a>…
题目传送门 题意:有多个矩形分布在[0, 0]到[R, R]的的范围内,画一条竖线分割成两块矩形,使得左边包括矩形的面积大于等于右边的面积,在这个前提下使得画的竖线尽量远 分析:二分答案,当面积相等时,判断再往右一个单位是否还可以相等,若不行则答案唯一确定,否则可以往右移动,即最后的竖线要不在一个矩形内或者在矩形边缘时最优. #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 1e4…
2015区域赛北京赛区的三水,当时在赛场上没做出的原因是复杂度分析不正确导致把方法想复杂了.近来复习复杂度分析,觉得不能只是笼统地看渐进复杂度(big-O),更应根据算法的伪码计算真正的以基本操作数为变量的时间复杂度T(n). 题意:在二维坐标系第一象限中,将一块顶点在原点边长为R的正方形土地用直线x=n一分为二,左侧分给Wei,右侧分给Huo. 土地中包含N个绿洲,每个绿洲是一个矩形,其位置和大小用四元组(L,T,W,H)表示,其中(L,T)为其左上方顶点的坐标,W,H为其宽度和高度.绿洲互不…
题目链接:http://hihocoder.com/problemset/problem/1249 题目大意:有一个大正方形里面有好多不重叠的小矩形,怎么找出一条竖线分割这个正方形,使得两边的矩形面积尽量相等并且正方形左边的面积比右边大 思路:做两次二分就好了 #include <stdio.h> #include <iostream> #include <algorithm> using namespace std; #define xx first #define…
Walk in the Park 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2222 Descriptionww.co You are responsible for inspecting the trees located in a park, to make sure they remain health…
Strange Antennas Problem's Link: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=87213 Mean: 给你一个N*N的网格,有M个雷达,每个雷达的扫射区域是一个直角边长为P的等腰直角三角形,能够向以直角顶点为中心的四个象限扫射. 雷达之间存在信号屏蔽,只有被奇数个雷达扫射到的区域才能被信号覆盖.求被信号覆盖的区域是多少. analyse: 因为给的都是整数点,这样就不涉及到计算几何了. N…
题目链接: http://acm.hust.edu.cn/vjudge/problem/87213 Strange Antennas Time Limit: 3000MS 题意 一个雷达能够辐射到的范围为等腰三角形,现在给你雷达的坐标,辐射范围和方向,问你求被奇数个雷达辐射到的网格有多少个. 题解 首先,雷达是建在交叉点上的,而考虑覆盖范围是在网格上的,所以需要坐标转换(题目样例第四行有错,应为1,5,4,0). 其次我们可以考虑每一行都做一遍,然后枚举每个雷达对这一行的影响,没个雷达对这一行的…
题意:给平面上的 n 个点,找出一个矩形,使得边界上包含尽量多的点. 析:如果暴力那么就是枚举上下边界,左右边界,还得统计个数,时间复杂度太高,所以我们考虑用扫描线来做,枚举上下边界, 然后用其他方法来确定左右边界.我们定义left[i] 表示竖线左边位于上下边界上的点数(不包含在竖线上的点),on[i]表示竖线 i 上的点, 但不包含上下边界上的点,in[i]表示竖线 i 的上的点,但是包含上下边界上的点.那么我们可以递推.最后矩形边界上的点数为 left[i] - left[j] + on[…
题意:给定m*n的矩阵,有的是空地有的是墙,找出一个面积最大的子矩阵. 析:如果暴力,一定会超时的.我们可以使用扫描线,up[i][j] 表示从(i, j)向上可以到达的最高高度,left[i][j]表示(i, j) 的左边界,right[i][j]右边界. 这三个可以用递推来实现.从向下扫描,每次更新最大值. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #i…
题意:给定上一个矩形照相机和 n 个流星,问你照相机最多能拍到多少个流星. 析:直接看,似乎很难解决,我们换一个思路,我们认为流星的轨迹就没有用的,我们可以记录每个流星每个流星在照相机中出现的时间段, 然后我们可以枚举时间段么?不行,这个是实数集上的,所以我们用扫描线,就相当于在x轴上有n个区间,我们从左到右拿一个竖线来扫描, 如果找到一个左端点,那么就加1,找到一个右端点就减1,注意,我们在排序时,要先按左端点排,再按右端点,不断更新答案即可, 并用我们可以避免使用浮点数. 代码如下: #pr…
Farming Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1375    Accepted Submission(s): 402 Problem Description You have a big farm, and you want to grow vegetables in it. You're too lazy to se…
Weird Advertisement Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=18802 Description 2DPlaneLand is a land just like a huge 2D plane. The range of X axis is 0 to 109 and the range ofY axis…
UVALive - 4108 SKYLINE Time Limit: 3000MS     64bit IO Format: %lld & %llu Submit Status uDebug Description   The skyline of Singapore as viewed from the Marina Promenade (shown on the left) is one of the iconic scenes of Singapore. Country X would a…
UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device with a variable electric resistance. It has two terminals and some kind of control mechanism (often a dial, a wheel or a slide) with which the resistance…
UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here comes a problem about words. Know- ing that Ray has a photographic memory and this may not trouble him, Neal gives it to Jiejie. Since Jiejie can’t remem…
D. Slalom time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Little girl Masha likes winter sports, today she's planning to take part in slalom skiing. The track is represented as a grid comp…
题目链接:http://codeforces.com/contest/522/problem/D 题目大意:  给你一个长度为n的序列,然后有m次查询,每次查询输入一个区间[li,lj],对于每一个查询,输出在这个区间内的两个相等的数的最短距离,如果没有相等的则输出-1. 线段树+扫描线,线段树维护的值是区间的最小值,从后往前扫,然后每次要做的事有两个: 1.判断当前这个位置 i 的数刚刚是不是出现过,假设刚刚出现的位置是 l ,如果出现过,则在线段树中把l这个位置的值更新为 l - i,同时更…
/* 大连热身B题 不要低头,不要放弃,不要气馁,不要慌张 题意: 坐标平面内给很多个点,放置一个边长为r的与坐标轴平行的正方形,问最多有多少个点在正方形内部. 思路: 按照x先排序,然后确定x在合法范围内后按照y排序,进行扫描线. */ #include<bits/stdc++.h> using namespace std; ]; struct st{ void read(){ scanf("%d%d",&x,&y); } int x,y; }; st j…
Atitit 图像扫描器---基于扫描线 调用范例 * @throws FileExistEx */ public static void main(String[] args) throws FileExistEx { String s = "C:\\00p\\a1115_210836_162 dilate.jpg.png"; String ext = filex.getExtName(s); // s="C:\\00capch\\p5.jpg"; Buffere…
2995 楼房  时间限制: 1 s  空间限制: 256000 KB  题目等级 : 黄金 Gold 题解       题目描述 Description 地平线(x轴)上有n个矩(lou)形(fang),用三个整数h[i],l[i],r[i]来表示第i个矩形:矩形左下角为(l[i],0),右上角为(r[i],h[i]).地平线高度为0.在轮廓线长度最小的前提下,从左到右输出轮廓线. 输入描述 Input Description 第一行一个整数n,表示矩形个数 以下n行,每行3个整数h[i],l…
4059: [Cerc2012]Non-boring sequences Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 440  Solved: 160[Submit][Status][Discuss] Description 我们害怕把这道题题面搞得太无聊了,所以我们决定让这题超短.一个序列被称为是不无聊的,仅当它的每个连续子序列存在一个独一无二的数字,即每个子序列里至少存在一个数字只出现一次.给定一个整数序列,请你判断它是不是不无聊的. In…
4422: [Cerc2015]Cow Confinement Time Limit: 50 Sec  Memory Limit: 512 MBSubmit: 61  Solved: 26[Submit][Status][Discuss] Description 一个10^6行10^6列的网格图,上面有一些牛.花和一些矩形围栏,围栏在格子的边界上,牛和花在格子里,牛只能向下或向右走,牛也不能穿过围栏和地图边界,求每头牛它能到达的花的数量.注意栅栏不会相交     Input 第一行一个数f表示矩…
Stars in Your Window Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11706   Accepted: 3183 Description Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beaut…
题目链接: 传送门 Prime Land Time Limit: 1000MS     Memory Limit: 10000K Description Everybody in the Prime Land is using a prime base number system. In this system, each positive integer x is represented as follows: Let {pi}i=0,1,2,... denote the increasing…
线段树的单点更新+区间求和 hdu1166敌兵布阵 Input 第一行一个整数T,表示有T组数据. 每组数据第一行一个正整数N(N<=),表示敌人有N个工兵营地 ,接下来有N个正整数,第i个正整数ai代表第i个工兵营地里开始时有ai个人(<=ai<=). 接下来每行有一条命令,命令有4种形式: () Add i j,i和j为正整数,表示第i个营地增加j个人(j不超过30) ()Sub i j ,i和j为正整数,表示第i个营地减少j个人(j不超过30); ()Query i j ,i和j为…