Submission #643119


Source Code Expand

import java.util.Scanner

/**
 * Created by sonetsuyoshi on 2015/12/16.
 */
object Main extends App {
  val sc = new Scanner(System.in)
  val text = sc.next
  val sb = new StringBuilder()
  sb.append(text(0))
  val rep = text.drop(1).foldLeft(1, text(0), sb){case ((count: Int, c1: Char, sb: StringBuilder), c2: Char) =>
    if(c1 == c2) {
      (count + 1, c1, sb)
    }
    else {
      sb.append(count)
      sb.append(c2)
      (1, c2, sb)
    }
  }

  sb.append(rep._1)
  println(sb.toString)
}

Submission Info

Submission Time
Task B - 高橋くんと文字列圧縮
User henohenotsuyoshi
Language Scala (2.9.1)
Score 100
Code Size 522 Byte
Status AC
Exec Time 989 ms
Memory 43112 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 3
AC × 33
Set Name Test Cases
Sample subtask0_1.txt, subtask0_2.txt, subtask0_3.txt
All 0.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, subtask0_1.txt, subtask0_2.txt, subtask0_3.txt
Case Name Status Exec Time Memory
0.txt AC 887 ms 42944 KB
1.txt AC 874 ms 42920 KB
10.txt AC 857 ms 42968 KB
11.txt AC 868 ms 42992 KB
12.txt AC 867 ms 42944 KB
13.txt AC 863 ms 42988 KB
14.txt AC 883 ms 42980 KB
15.txt AC 863 ms 43056 KB
16.txt AC 872 ms 43080 KB
17.txt AC 880 ms 43052 KB
18.txt AC 847 ms 43048 KB
19.txt AC 869 ms 43016 KB
2.txt AC 863 ms 42992 KB
20.txt AC 903 ms 42964 KB
21.txt AC 989 ms 42940 KB
22.txt AC 918 ms 43024 KB
23.txt AC 910 ms 43012 KB
24.txt AC 933 ms 42936 KB
25.txt AC 889 ms 43028 KB
26.txt AC 866 ms 42884 KB
27.txt AC 898 ms 43112 KB
28.txt AC 875 ms 43020 KB
29.txt AC 872 ms 43048 KB
3.txt AC 884 ms 42996 KB
4.txt AC 869 ms 42964 KB
5.txt AC 876 ms 42944 KB
6.txt AC 867 ms 42988 KB
7.txt AC 863 ms 42996 KB
8.txt AC 861 ms 42972 KB
9.txt AC 863 ms 43008 KB
subtask0_1.txt AC 855 ms 42884 KB
subtask0_2.txt AC 856 ms 42908 KB
subtask0_3.txt AC 847 ms 42944 KB