Submission #2251449


Source Code Expand

object Main extends App {
  val down: String => Int = x => {
    val hour:Int = x.slice(0, 2).toInt
    val minute:Int = x.slice(2, 4).toInt / 5
    hour*12 + minute
  }
  val up: String => Int = x => {
    val hour:Int = x.slice(0, 2).toInt
    val minute:Int = (x.slice(2, 4).toInt+4) / 5
    hour*12 + minute
  }
  val N = readInt
  var result:List[(Int, Char)] = Nil
  (0 until N).map(_ => readLine)
    .foreach {
      x =>
       val times = x.split("-")
       val start = down(times(0))
       val end = up(times(1))
       result = insertS(result, start, end)
       //println("result:" + result)
       //println()
    }
  def insertS(list:List[(Int, Char)], start:Int, end:Int):List[(Int, Char)] = {
    //println("call:insertS(" + list + ", " + start + ", " + end + ")")
    list match {
      case Nil => (start, 's')::(end, 'e')::Nil
      case x::xs if x._1 < start => x::insertS(xs, start, end)
      case x::xs if x._1 == start =>
        if(x._2 == 's') x::insertE(xs, end) else insertE(xs, end)
      case x::xs if x._1 > start =>
        if(x._2 == 's') {
          if(x._1 > end) (start, 's')::(end, 'e')::x::xs else (start, 's')::insertE(xs, end)
        } else {
          if(x._1 > end) x::xs else insertE(xs, end)
        }
    }
  }
  def insertE(list:List[(Int, Char)], end:Int):List[(Int, Char)] = {
    //println("call:insertE(" + list + ", " + end + ")")
    list match {
      case Nil => (end, 'e')::Nil
      case x::xs if x._1 < end => insertE(xs, end)
      case x::xs if x._1 == end =>
        if(x._2 == 's') xs else x::xs
      case x::xs if x._1 > end =>
        if(x._2 == 's') (end, 'e')::x::xs else x::xs
    }
  }
  def printer(x:Int):String = {
    val i1 = (x%12)*5
    val i2 = (x/12)
    "%02d".format(i2) + "%02d".format(i1)
  }
  result.foreach {
    case (i, 's') => print(printer(i)+"-")
    case (i, 'e') => println(printer(i))
  }
}

Submission Info

Submission Time
Task D - 感雨時刻の整理
User RainDrop
Language Scala (2.11.7)
Score 100
Code Size 1946 Byte
Status AC
Exec Time 762 ms
Memory 46424 KB

Compile Error

warning: there were two deprecation warnings; re-run with -deprecation for details
one warning found

Judge Result

Set Name all
Score / Max Score 100 / 100
Status
AC × 48
Set Name Test Cases
all 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, cho_cho_chokudai.txt, chokudai_ga_cho.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt, test_37.txt, test_38.txt, test_39.txt, test_40.txt, test_41.txt, test_42.txt, test_43.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 319 ms 25248 KB
00_sample_02.txt AC 319 ms 25272 KB
00_sample_03.txt AC 319 ms 23612 KB
cho_cho_chokudai.txt AC 733 ms 42464 KB
chokudai_ga_cho.txt AC 709 ms 38876 KB
test_01.txt AC 402 ms 27984 KB
test_02.txt AC 378 ms 25276 KB
test_03.txt AC 399 ms 28352 KB
test_04.txt AC 400 ms 27956 KB
test_05.txt AC 400 ms 28192 KB
test_06.txt AC 328 ms 23616 KB
test_07.txt AC 325 ms 23612 KB
test_08.txt AC 328 ms 25404 KB
test_09.txt AC 348 ms 23484 KB
test_10.txt AC 349 ms 25308 KB
test_11.txt AC 352 ms 25280 KB
test_12.txt AC 339 ms 25536 KB
test_13.txt AC 331 ms 23500 KB
test_14.txt AC 346 ms 25280 KB
test_15.txt AC 346 ms 25280 KB
test_16.txt AC 329 ms 23576 KB
test_17.txt AC 342 ms 25412 KB
test_18.txt AC 330 ms 25272 KB
test_19.txt AC 337 ms 25268 KB
test_20.txt AC 339 ms 25408 KB
test_21.txt AC 669 ms 38724 KB
test_22.txt AC 735 ms 46424 KB
test_23.txt AC 713 ms 42052 KB
test_24.txt AC 732 ms 40324 KB
test_25.txt AC 670 ms 38908 KB
test_26.txt AC 738 ms 39940 KB
test_27.txt AC 727 ms 42388 KB
test_28.txt AC 712 ms 39840 KB
test_29.txt AC 326 ms 25164 KB
test_30.txt AC 329 ms 25404 KB
test_31.txt AC 504 ms 33468 KB
test_32.txt AC 323 ms 25428 KB
test_33.txt AC 712 ms 39112 KB
test_34.txt AC 321 ms 25264 KB
test_35.txt AC 340 ms 25168 KB
test_36.txt AC 705 ms 42728 KB
test_37.txt AC 762 ms 44932 KB
test_38.txt AC 708 ms 37648 KB
test_39.txt AC 747 ms 39968 KB
test_40.txt AC 760 ms 40868 KB
test_41.txt AC 698 ms 41820 KB
test_42.txt AC 710 ms 40728 KB
test_43.txt AC 730 ms 39668 KB