hdu1007】的更多相关文章

一,效果图. 二,工程图. 三,代码 RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController : UIViewController { UIButton * leftButton; UIButton * rightButton; UIViewController * firstController; UIViewController * secondController; } @end RootVie…
Have you ever played quoit in a playground? Quoit is a game in which flat rings are pitched at some toys, with all the toys encircled awarded.In the field of Cyberground, the position of each toy is fixed, and the ring is carefully designed so it can…
http://acm.hdu.edu.cn/showproblem.php?pid=1007 直接见代码吧.不过这个是N*logN*logN的 尽管如此,我怎么感觉我的比他们的还快??? #include <map> #include <set> #include <stack> #include <queue> #include <cmath> #include <ctime> #include <vector> #in…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1007 简单裸题,测测模板,G++速度快了不少,应该是编译的时候对比C++优化了不少.. //STATUS:G++_AC_1703MS_5004KB #include <functional> #include <algorithm> #include <iostream> //#include <ext/rope> #include <fstream>…
Quoit Design Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 30505    Accepted Submission(s): 8017 Problem Description Have you ever played quoit in a playground? Quoit is a game in which flat…
Quoit Design Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 28539    Accepted Submission(s): 7469 Problem Description Have you ever played quoit in a playground? Quoit is a game in which flat…
-- 点我 -- 题目大意 :给你一堆点,求一个最小圆能够覆盖两个点的半径(最近两点距离的一半): 最多100000个点,暴力即O(n^2)会超时,考虑二分,先求左边最短距离dl,右边dr, 和一个点左, 一个点在右的情况, 求d; #include<bits/stdc++.h> using namespace std; #define lint long long #define maxn 100005 #define mod 1e9+7 struct point { double x, y…
利用二分的方法来计算,应该是说利用分治的方法吧! 刚开始感觉时间会爆 后来发现嘎嘎居然没有 ,嗨自己算错了时间: #include <iostream> #include<cstdio> #include<string.h> #include<algorithm> #include<cmath> using namespace std; struct point { double x,y; point (double a=0,double b=0…
Quoit Design Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 30919 Accepted Submission(s): 8120 Problem Description Have you ever played quoit in a playground? Quoit is a game in which flat rings…
Quoit Design Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 54667    Accepted Submission(s): 14401 Problem Description Have you ever played quoit in a playground? Quoit is a game in which flat…
http://acm.hdu.edu.cn/showproblem.php?pid=1007 题目大意:给n个点,求点对最短距离/2. —————————————————————— 平面分治裸题. 暂时还不想讲为什么这么做. 所以原理暂割. #include<cmath> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespac…
Problem Description Have you ever played quoit in a playground? Quoit is a game in which flat rings are pitched at some toys, with all the toys encircled awarded. In the field of Cyberground, the position of each toy is fixed, and the ring is careful…
突发奇想,用双线程似乎可以优化一些暴力 比如说平面最近点对这个题目,把点复制成2份 一份按照x排序,一份按照y排序 然后双线程暴力处理,一份处理x,一份处理y 如果数据利用x递减来卡,那么由于双线程,它卡不住y 如果数据利用y递减来卡,那么卡不住x 这样暴力n^2就可以过了 #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algori…
这题卡了一天,上午开始看算法导论,然后实现了,一开始是wa,后来TLE,由于我开始的实现方式比较笨,而且在递归调用的时候很是混乱,用了好多数组.导致我的代码不断的出问题.具体是算法导论33-4. 后来改动了一点,也是看到别人代码改的,我把两个代码都写上,大家一看便知! 在实现分治的时候,我是把左右两个分组都复制了,然后传递的是一个数组,好慢啊...改动就是把参数传递改成传的是地址了,这样就不用复制结构体数组啦,不知道节省了多少力气,(⊙o⊙)… 首先是AC代码 #include <iostrea…
一年前学长讲这题的时候,没听懂.自己搜解题报告也看不懂,放了一年. 现在对分治和递归把握的比一年前更加熟悉,这题也就攻克了. 题意:给你一堆点让你求近期两点之间距离的一半,假设用暴力的话O(n*n)明显会超时.那么我们就用分治思想,将全部点依照横坐标x排序,然后取中间的mid.分着求1-mid,mid-n,这样递归求解,递归仅仅须要logn级别就能够完毕递归.这有点类似二分思想. 1.我们取左边点对最小和右边点对最小比較,取最小的,记做d 2:可是近期点有可能一个点在左边.一个点在右边,所以要单…
Quoit Design 看懂题意以后发现就是找平面最近点对间距离除以2. 平面上最近点对是经典的分治,我的解析 直接上代码 #include<bits/stdc++.h> using namespace std; #define int long long const int N=1000005; const double inf=1e12; struct node{ double x,y; }p[N]; bool cmp(node a,node b) { if(a.x==b.x)retur…
http://acm.hdu.edu.cn/showproblem.php?pid=1007 分治法的经典应用,复杂度可以证明为nlognlogn #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <map> #include <stack> #include <…
---恢复内容开始--- Quoit Design Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 47126    Accepted Submission(s): 12323 Problem Description Have you ever played quoit in a playground? Quoit is a game…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=2665 代码: //#include<bits/stdc++.h> #include<iostream> #include<cmath> #include<algorithm> #define fi first #define se second #define INF 0x3f3f3f3f #define fio ios::sync_with_stdio(fal…
题目大意: 给定一堆点集,在这一堆点集中找到一组点集它们之间的距离达到最短 对于HDU1007因为求圆的半径,所以距离还要除以2 普通情况下,可以将nge点,将任意两个点之间的距离都算一遍,在循环过程中,每次取到距离的较小值 但数据量大的话,这种O(n^2)的方法肯定是不合理的 转化为O(nlogn)的方法是可取的 这里采用分治的方法 我们希望尽可能的均匀分配,也就是让左右两端所含有的点的数目一样多,所以一开始就根据以x优先排序 , 然后取中值作为分割边 int fenzhi(int l , i…
题目链接:https://vjudge.net/problem/HDU-1007 题意:给定n个点,求平面距离最小点对的距离除2. 思路:分治求最小点对,对区间[l,r]递归求[l,mid]和[mid+1,r]的最小点对,取两者中的小者设为d.然后处理一个点在左区间,一个点在右区间的情况.一个点P在左区间,如果使它与右区间Q一个点距离小于d的话,那么P到mid的距离一定小于的,Q也是,且P和Q的纵坐标之差小于d.可以证明这样的Q点最多6个.那么我们把符合到mid距离小于d的点按y排序后,遍历一遍…