本文整理汇总了C#中Vector2D.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2D.Select方法的具体用法?C# Vector2D.Select怎么用?C# Vector2D.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector2D
的用法示例。
在下文中一共展示了Vector2D.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
// n, m, and l (1 <= n,m <= 10^5, 1 <= l <= 10^9),
// the number of squares, the number of points and the side length of each square.
var split = Console.ReadLine().Split(' ');
int n = Convert.ToInt32(split[0]);
int m = Convert.ToInt32(split[1]);
int l = Convert.ToInt32(split[2]);
// Read in Squares
var squares = new Vector2D[n];
for (int i = 0; i < n; i++)
{
var coords = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
squares[i] = new Vector2D(coords[0], coords[1]);
}
// Read in Points
var points = new Vector2D[m];
for (int i = 0; i < m; i++)
{
var coords = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
points[i] = new Vector2D(coords[0], coords[1]);
}
// Find the Point that is contained in the maximum amount of squares
// Return the maximum number of squares
// Bruteforce: Worstcase (n * m) => 10^10
// TODO: Bruteforce solutions is to slow for the contest, lead to timeout
/* Linq Solution */
int max = points.Select(p => squares.Count(s => Contains(s, l, p))).Max();
/* Parallel Solution
int[] res = new int[m];
Parallel.ForEach(Partitioner.Create(0, m), (range) => {
for (int i = range.Item1; i < range.Item2; i++) { res[i] = squares.Count(s => Contains(s, l, points[i])); }
});
int max = res.Max();
*/
Console.WriteLine(max);
}