public bool DoesIntersect(LumberLog other) { if (this.MinY <= other.MaxY && this.MaxY >= other.MinY && this.MinX <= other.MaxX && this.MaxX >= other.MinX) { return(true); } return(false); }
private static void ReadInput() { var line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var numberOfLogs = line[0]; var numberOfQueries = line[1]; logs = new LumberLog[numberOfLogs]; graph = new List <int> [numberOfLogs]; for (int i = 0; i < numberOfLogs; i++) { graph[i] = new List <int>(); } for (int i = 0; i < numberOfLogs; i++) { var coordinates = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); var log = new LumberLog(coordinates[0], coordinates[2], coordinates[3], coordinates[1]); for (int j = 0; j < i; j++) { if (log.DoesIntersect(logs[j])) { graph[i].Add(j); graph[j].Add(i); } } logs[i] = log; } queries = new List <string>(); for (int i = 0; i < numberOfQueries; i++) { queries.Add(Console.ReadLine()); } connComponents = new List <List <int> >(); visited = new bool[numberOfLogs]; nodesComponents = new int[numberOfLogs]; }