Submission #1865318


Source Code Expand

import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val N, M = sc.nextInt()
  val graph = Array.fill[List[Int]](N+1)(Nil)
  for (_ <- 1 to M) {
    val a, b = sc.nextInt()
    graph(a) = b :: graph(a)
    graph(b) = a :: graph(b)
  }

  if(dfs(1, 0))
    println("POSSIBLE")
  else
    println("IMPOSSIBLE")

  def dfs(node: Int, cnt: Int): Boolean = {
    if (node == N)
      true
    else {
      if(cnt == 2)
        false
      else
        for(e <- graph(node))
          dfs(e, cnt+1)
    }
  }
}

Submission Info

Submission Time
Task C - Cat Snuke and a Voyage
User Gobi
Language Scala (2.11.7)
Score 0
Code Size 571 Byte
Status CE

Compile Error

./Main.scala:26: error: type mismatch;
 found   : Unit
 required: Boolean
        for(e <- graph(node))
              ^
one error found