import java.util.TreeSet /** * Main idea is to transpose the coordinates to a general basepoint. To do this is, I make sure all numbers * are positive and move it as close as possible to (0,0). * Pitfall: The dots don't have to appear in the same order from the input. e.g. for example 1: 2 2 0 2 1 1 2 1 0 0 1 This makes an extra ordering step necessary. */ fun main() { val input = System.`in`.bufferedReader() val characters = input.readLine().toInt() val chars = mutableSetOf>() repeat(characters) { val dots = input.readLine().toInt() var lowX = 2000 var lowY = 2000 val dotList = mutableListOf() repeat(dots) { val (x, y) = input.readLine().split(" ").map { it.toInt() + 1000 } lowX = lowX.coerceAtMost(x) lowY = lowY.coerceAtMost(y) dotList.add(x to y) } chars.add(dotList.map { (x, y) -> (x - lowX) to (y - lowY) }.toCollection(TreeSet(comparator))) } println(chars.size) } typealias Coordinate = Pair val comparator = Comparator { o1, o2 -> when (o1.first) { o2.first -> o1.second.compareTo(o2.second) else -> o1.first.compareTo(o2.first) } } /* x,y in [-1000 .. 0 .. 1000] all + 1000 -> transpose to 0 */