ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

How to write Scala solutions

Scala programs are compiled on the server by the Scala 2.11.2. The compiler is invoked with the following parameters:

scalac -optimise -feature %1

Solutions are executed by the Java 8 interpreter:

java -client -Xmx544m -Xss64m -DONLINE_JUDGE
    -classpath .;scala-library.jar YourClassName

You can find the compiler here.

Examples of solving problems

A sample solution for the 1000. A + B problem in Scala:

object Main extends App {
   println(readLine().split(" ").map(_.toInt).sum)
}

You can also use standard JDK classes:

import java.util.Scanner
object Sum {
   def main(args: Array[String]) {
      val in = new Scanner(System.in)
      println(in.nextInt() + in.nextInt())
      in.close()
   }
}

A sample solution for the 1001. Reverse Root in Scala:

import io.Source
object ReverseRoot extends App {
   val longs = Source.stdin.getLines().flatMap(
      _.split(" ").filter(!_.isEmpty).map(_.toLong)).toArray
   println(longs.reverse.map(t => math.sqrt(t)).mkString("\n"))
}

Earlier compilers

  • The Scala 2.10.1 was used until October, 3 2014.