import kotlin.system.exitProcess val br = System.`in`.bufferedReader() fun readLine(): String? = br.readLine() fun readString() = readLine()!! fun readStrings() = readLine()?.split(" ")?.filter { it.isNotEmpty() } ?: listOf() fun readInts() = readStrings().map { it.toInt() }.toIntArray() const val MAX_STACK_SIZE: Long = 128 * 1024 * 1024 fun main() { val thread = Thread(null, ::run, "solve", MAX_STACK_SIZE) thread.setUncaughtExceptionHandler { _, e -> e.printStackTrace(); exitProcess(1) } thread.start() } fun run() { val (H, W) = readInts() val S = Array(H) { readString().toCharArray() } output(solve(H, W, S)) } typealias Vector2 = Pair operator fun Vector2.minus(other: Vector2): Vector2 { val (x1, y1) = this val (x2, y2) = other return Vector2(x1 - x2, y1 - y2) } infix fun Vector2.cross(other: Vector2): Int { val (x1, y1) = this val (x2, y2) = other return x1 * y2 - y1 * x2 } fun solve(H: Int, W: Int, S: Array): Array { val rows = H val cols = W val stars = mutableListOf>() for (r in 0 until rows) { for (c in 0 until cols) { if (S[r][c] == '*') stars.add(r to c) } } for (r in 0 until rows) { for (c in 0 until cols) { if (S[r][c] == '*') continue val a = stars[1] - stars[0] val b = Vector2(r, c) - stars[0] if (a cross b == 0) continue S[r][c] = '*' return S } } return S } fun output(res: Array) = res.joinToString("\n") { it.joinToString("") } .apply { println(this) }