Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math._
- import scala.util._
- /**
- * Auto-generated code below aims at helping you parse
- * the standard input according to the problem statement.
- **/
- object Player extends App {
- // w: number of columns.
- // h: number of rows.
- val Array(w, h) = for(i <- readLine split " ") yield i.toInt
- val tunnelMap = (1 to h).toList.map(_ -> readLine.split(" ").map(_.toInt).toList)
- val exit = readInt
- val tileFlow = Map(
- 0 -> null,
- 1 -> Map("TOP" -> "BOTTOM", "LEFT" -> "BOTTOM", "RIGHT" -> "BOTTOM"),
- 2 -> Map("LEFT" -> "RIGHT", "RIGHT" -> "LEFT"),
- 3 -> Map("TOP" -> "BOTTOM"),
- 4 -> Map("TOP" -> "LEFT", "RIGHT" -> "BOTTOM"),
- 5 -> Map("TOP" -> "RIGHT", "LEFT" -> "BOTTOM"),
- 6 -> Map("TOP" -> null, "LEFT" -> "RIGHT", "RIGHT" -> "LEFT"),
- 7 -> Map("TOP" -> "BOTTOM", "RIGHT" -> "BOTTOM"),
- 8 -> Map("LEFT" -> "BOTTOM", "RIGHT" -> "BOTTOM"),
- 9 -> Map("LEFT" -> "BOTTOM", "TOP" -> "BOTTOM"),
- 10 -> Map("TOP" -> "LEFT", "LEFT" -> null),
- 11 -> Map("TOP" -> "RIGHT", "RIGHT" -> null),
- 12 -> Map("RIGHT" -> "BOTTOM"),
- 13 -> Map("LEFT" -> "BOTTOM")
- )
- // game loop
- while(true) {
- val Array(_xi, _yi, pos) = readLine split " "
- val xi = _xi.toInt
- val yi = _yi.toInt
- val tile = tunnelMap(yi)._2(xi)
- val flow = tileFlow(tile)(pos)
- val (nx, ny) = flow match {
- case "LEFT" => (xi - 1, yi)
- case "RIGHT" => (xi + 1, yi)
- case "BOTTOM" => (xi, yi + 1)
- }
- println(s"$nx $ny")
- }
- }
Add Comment
Please, Sign In to add comment