Last active
July 29, 2016 12:34
-
-
Save waynejo/bfcdcb960a9030d183e814e39709cd5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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