Submission #345127


Source Code Expand

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
 
public class Main {
	
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        
        char[] inputs = sc.next().toCharArray();
        
        StringBuilder sb = new StringBuilder();
        
        int count = 1;
        char prev = inputs[0];
        for(int i = 1; i < inputs.length; i++){
        	final char cur = inputs[i];
        	
        	if(prev == cur){
        		count++;
        	}else{
        		sb.append(prev);
        		sb.append(count);
        		
        		prev = cur;
        		count = 1;
        	}
        }
        
        sb.append(prev);
        sb.append(count);
        
        System.out.println(sb.toString());
    }
 
    public static class Scanner {
        private BufferedReader br;
        private StringTokenizer tok;
 
        public Scanner(InputStream is) throws IOException {
            br = new BufferedReader(new InputStreamReader(is));
        }
 
        private void getLine() throws IOException {
            while (!hasNext()) {
                tok = new StringTokenizer(br.readLine());
            }
        }
 
        private boolean hasNext() {
            return tok != null && tok.hasMoreTokens();
        }
 
        public String next() throws IOException {
            getLine();
            return tok.nextToken();
        }
 
        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
 
        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }
 
        public void close() throws IOException {
            br.close();
        }
    }
 
}

Submission Info

Submission Time
Task B - 高橋くんと文字列圧縮
User mondatto
Language Java (OpenJDK 1.7.0)
Score 100
Code Size 2136 Byte
Status AC
Exec Time 492 ms
Memory 20712 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 409 ms 20712 KB
1.txt AC 412 ms 20580 KB
10.txt AC 461 ms 20640 KB
11.txt AC 404 ms 20536 KB
12.txt AC 405 ms 20624 KB
13.txt AC 413 ms 20520 KB
14.txt AC 407 ms 20628 KB
15.txt AC 409 ms 20632 KB
16.txt AC 406 ms 20592 KB
17.txt AC 465 ms 20692 KB
18.txt AC 415 ms 20596 KB
19.txt AC 412 ms 20644 KB
2.txt AC 457 ms 20552 KB
20.txt AC 407 ms 20596 KB
21.txt AC 421 ms 20528 KB
22.txt AC 411 ms 20572 KB
23.txt AC 406 ms 20628 KB
24.txt AC 404 ms 20544 KB
25.txt AC 413 ms 20648 KB
26.txt AC 409 ms 20600 KB
27.txt AC 432 ms 20600 KB
28.txt AC 492 ms 20656 KB
29.txt AC 419 ms 20528 KB
3.txt AC 413 ms 20564 KB
4.txt AC 414 ms 20644 KB
5.txt AC 413 ms 20644 KB
6.txt AC 415 ms 20560 KB
7.txt AC 420 ms 20672 KB
8.txt AC 416 ms 20628 KB
9.txt AC 425 ms 20632 KB
subtask0_1.txt AC 423 ms 20680 KB
subtask0_2.txt AC 419 ms 20584 KB
subtask0_3.txt AC 420 ms 20588 KB