Submission #345274
Source Code Expand
import java.io.*; import java.util.*; public class Main { void run() { String s = read(); StringBuilder bld = new StringBuilder(); for (int i = 0; i < s.length(); ) { int add = 0; for (int j = 0; i + j < s.length(); j++) { if (s.charAt(i + j) != s.charAt(i)) { break; } add++; } bld.append("" + s.charAt(i) + add); i += add; } sysout.println(bld); } public static void main(String[] args) { new Main().run(); } // flush automatically iff you call `println` or `printf` or `format`. PrintWriter sysout = new PrintWriter(System.out, true); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer buffer = new StringTokenizer(""); String read() { if (!buffer.hasMoreTokens()) { try { buffer = new StringTokenizer(in.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return buffer.nextToken(); } int readInt() { return Integer.parseInt(read()); } long readLong() { return Long.parseLong(read()); } double readDouble() { return Double.parseDouble(read()); } String readLine() { buffer = new StringTokenizer(""); try { return in.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } }
Submission Info
Submission Time | |
---|---|
Task | B - 高橋くんと文字列圧縮 |
User | arosh |
Language | Java (OpenJDK 1.7.0) |
Score | 100 |
Code Size | 1648 Byte |
Status | AC |
Exec Time | 521 ms |
Memory | 20852 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
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 | 431 ms | 20788 KB |
1.txt | AC | 437 ms | 20792 KB |
10.txt | AC | 434 ms | 20676 KB |
11.txt | AC | 431 ms | 20796 KB |
12.txt | AC | 429 ms | 20644 KB |
13.txt | AC | 436 ms | 20652 KB |
14.txt | AC | 442 ms | 20624 KB |
15.txt | AC | 440 ms | 20752 KB |
16.txt | AC | 425 ms | 20656 KB |
17.txt | AC | 437 ms | 20664 KB |
18.txt | AC | 442 ms | 20660 KB |
19.txt | AC | 413 ms | 20628 KB |
2.txt | AC | 436 ms | 20852 KB |
20.txt | AC | 423 ms | 20756 KB |
21.txt | AC | 429 ms | 20716 KB |
22.txt | AC | 421 ms | 20772 KB |
23.txt | AC | 421 ms | 20624 KB |
24.txt | AC | 433 ms | 20528 KB |
25.txt | AC | 424 ms | 20660 KB |
26.txt | AC | 431 ms | 20676 KB |
27.txt | AC | 420 ms | 20688 KB |
28.txt | AC | 431 ms | 20660 KB |
29.txt | AC | 427 ms | 20644 KB |
3.txt | AC | 434 ms | 20784 KB |
4.txt | AC | 430 ms | 20660 KB |
5.txt | AC | 521 ms | 20784 KB |
6.txt | AC | 441 ms | 20788 KB |
7.txt | AC | 423 ms | 20784 KB |
8.txt | AC | 432 ms | 20784 KB |
9.txt | AC | 436 ms | 20804 KB |
subtask0_1.txt | AC | 408 ms | 20648 KB |
subtask0_2.txt | AC | 417 ms | 20732 KB |
subtask0_3.txt | AC | 424 ms | 20664 KB |