文件名称:5
介绍说明--下载内容均来自于网络,请自行研究使用
Graphics
本题关于排序与二分查找,又数据规模可达10^8,故选择long long型的数组作为数据结构。
算法思想大致如下:对于输入的x,y数组,先进行排序,以便一对一形成线段,然后,对于每一组询问,进行二分查找,查找过程如下:运用询问点到第mid条直线两端点向量的外积,若外积大于0说明该点在直线上方,等于0说明该点在直线上,否则说明该点在直线下方(当然同时求出询问点到第mid+1条直线两端点向量的外积以判断该点的准确位置)。这样的二分查找即可找出该点的位置。最后输出结果。
复杂度:因为此题中主要用了二分查找来判断,故复杂度为O(mlogn)。空间复杂度是 O(n)。
-Graphics
This topic on the sort and binary search, and data size up to 10 ^ 8, so the choice of long long-type array as a data structure.
The idea of the algorithm is as follows: For the input x, y array, the first sort in order to form a line segment, and then, for each set of queries, binary search, the search process is as follows: The outer product of the vector, if the outer product is greater than 0 that the point above the line, is equal to 0 that the point in the line, otherwise the point below the line (of course while the query point to the mid+ Of the outer product to determine the exact location of the point). This binary search can find the location of the point. Finally, the output.
Complexity: Because this problem is mainly used in the binary search to determine, so the complexity of O (mlogn). The spatial complexity is O (n).
本题关于排序与二分查找,又数据规模可达10^8,故选择long long型的数组作为数据结构。
算法思想大致如下:对于输入的x,y数组,先进行排序,以便一对一形成线段,然后,对于每一组询问,进行二分查找,查找过程如下:运用询问点到第mid条直线两端点向量的外积,若外积大于0说明该点在直线上方,等于0说明该点在直线上,否则说明该点在直线下方(当然同时求出询问点到第mid+1条直线两端点向量的外积以判断该点的准确位置)。这样的二分查找即可找出该点的位置。最后输出结果。
复杂度:因为此题中主要用了二分查找来判断,故复杂度为O(mlogn)。空间复杂度是 O(n)。
-Graphics
This topic on the sort and binary search, and data size up to 10 ^ 8, so the choice of long long-type array as a data structure.
The idea of the algorithm is as follows: For the input x, y array, the first sort in order to form a line segment, and then, for each set of queries, binary search, the search process is as follows: The outer product of the vector, if the outer product is greater than 0 that the point above the line, is equal to 0 that the point in the line, otherwise the point below the line (of course while the query point to the mid+ Of the outer product to determine the exact location of the point). This binary search can find the location of the point. Finally, the output.
Complexity: Because this problem is mainly used in the binary search to determine, so the complexity of O (mlogn). The spatial complexity is O (n).
(系统自动生成,下载前可以参看下载内容)
下载文件列表
5.cpp