Skip to content

Instantly share code, notes, and snippets.

@waynejo
Last active July 29, 2016 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waynejo/bfcdcb960a9030d183e814e39709cd5f to your computer and use it in GitHub Desktop.
Save waynejo/bfcdcb960a9030d183e814e39709cd5f to your computer and use it in GitHub Desktop.
package Main
import java.io.{FileInputStream, FileOutputStream}
import scala.annotation.tailrec
import scala.io.StdIn
object Main extends App {
Console.setIn(new FileInputStream("example.in"))
Console.setIn(new FileInputStream("B-small-practice.in"))
Console.setOut(new FileOutputStream("B-small-practice.out"))
Console.setIn(new FileInputStream("B-large-practice.in"))
Console.setOut(new FileOutputStream("B-large-practice.out"))
def solve(inputs:List[List[Int]]): String = {
inputs.flatten
.groupBy(x => x)
.filter{case (_, v) => 1 == v.size % 2}
.keys
.toList
.sorted
.mkString(" ")
}
val cases = StdIn.readLine().toInt
(1 to cases) foreach { i => {
val n = StdIn.readInt()
val inputs = for (x <- 0 until 2 * n - 1) yield StdIn.readLine().split(" ").map(_.toInt).toList
println(s"Case #$i: ${solve(inputs.toList)}")
}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment