Submission #345440
Source Code Expand
import java.util.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
public class Main{
// ArrayList<Integer> lis = new ArrayList<Integer>();
// ArrayList<String> lis = new ArrayList<String>();
// PriorityQueue<P> que = new PriorityQueue<P>();
// PriorityQueue<Integer> que = new PriorityQueue<Integer>();
// Stack<Integer> que = new Stack<Integer>();
//HashMap<Long,Long> map = new HashMap<Long,Long>();
// static long sum=0;
// 1000000007 (10^9+7)
static int mod = 1000000007;
//static int mod = 1000000009; ArrayList<Integer> l[]= new ArrayList[n];
// static int dx[]={1,-1,0,0};
//static int dy[]={0,0,1,-1};
// static int dx[]={1,-1,0,0,1,1,-1,-1};
// static int dy[]={0,0,1,-1,1,-1,1,-1};
//static Set<Integer> set = new HashSet<Integer>();
//static ArrayList<Integer> l[];
//static int parent[][],depth[],node,max_log;
// static ArrayList<Integer> nd[]= new ArrayList[2001];
public static void main(String[] args) throws Exception, IOException{
//Scanner sc =new Scanner(System.in);
Reader sc = new Reader(System.in);
//int n=sc.nextInt();//,m=sc.nextInt(),k=sc.nextInt();
//int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
//int n=sc.nextInt();//,k=sc.nextInt(),s=0;
char c[]=sc.nextString().toCharArray();
String s="";
for (int i = 0; i < c.length; i++) {
int a=0;
char x=c[i];
while(i<c.length && c[i]==x){i++;a++;}
s+=x+""+a;
i--;
}
System.out.println(s);
}
/*
static class P implements Comparable<P>{
int id, d; ;
P(int id,int d){
this.id=id;
this.d=d;
}
public int compareTo(P x){
// return (-x.d+d)>=0?1:-1 ; // ascend long
// return -x.d+d ; // ascend
return x.d-d ; //descend
}
}//*/
static void db(Object... os){
System.err.println(Arrays.deepToString(os));
}
static boolean validpos(int x,int y,int r, int c){
return x<r && 0<=x && y<c && 0<=y;
}
static boolean bit(int x,int k){
// weather k-th bit (from right) be one or zero
return ( 0 < ( (x>>k) & 1 ) ) ? true:false;
}
}
class Reader
{
private BufferedReader x;
private StringTokenizer st;
public Reader(InputStream in)
{
x = new BufferedReader(new InputStreamReader(in));
st = null;
}
public String nextString() throws IOException
{
while( st==null || !st.hasMoreTokens() )
st = new StringTokenizer(x.readLine());
return st.nextToken();
}
public int nextInt() throws IOException
{
return Integer.parseInt(nextString());
}
public long nextLong() throws IOException
{
return Long.parseLong(nextString());
}
public double nextDouble() throws IOException
{
return Double.parseDouble(nextString());
}
}
Submission Info
Submission Time |
|
Task |
B - 高橋くんと文字列圧縮 |
User |
mukku |
Language |
Java (OpenJDK 1.7.0) |
Score |
100 |
Code Size |
2862 Byte |
Status |
AC |
Exec Time |
368 ms |
Memory |
28880 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 |
339 ms |
28824 KB |
1.txt |
AC |
337 ms |
28736 KB |
10.txt |
AC |
315 ms |
21648 KB |
11.txt |
AC |
310 ms |
21700 KB |
12.txt |
AC |
316 ms |
21684 KB |
13.txt |
AC |
310 ms |
21552 KB |
14.txt |
AC |
307 ms |
21608 KB |
15.txt |
AC |
304 ms |
21660 KB |
16.txt |
AC |
303 ms |
21660 KB |
17.txt |
AC |
294 ms |
21632 KB |
18.txt |
AC |
296 ms |
21624 KB |
19.txt |
AC |
297 ms |
21640 KB |
2.txt |
AC |
321 ms |
28712 KB |
20.txt |
AC |
295 ms |
21588 KB |
21.txt |
AC |
297 ms |
21596 KB |
22.txt |
AC |
300 ms |
21552 KB |
23.txt |
AC |
296 ms |
21600 KB |
24.txt |
AC |
331 ms |
21540 KB |
25.txt |
AC |
304 ms |
21656 KB |
26.txt |
AC |
299 ms |
21656 KB |
27.txt |
AC |
293 ms |
21652 KB |
28.txt |
AC |
308 ms |
21652 KB |
29.txt |
AC |
368 ms |
21632 KB |
3.txt |
AC |
356 ms |
28880 KB |
4.txt |
AC |
338 ms |
28768 KB |
5.txt |
AC |
321 ms |
28812 KB |
6.txt |
AC |
321 ms |
28828 KB |
7.txt |
AC |
318 ms |
28844 KB |
8.txt |
AC |
320 ms |
28708 KB |
9.txt |
AC |
322 ms |
28708 KB |
subtask0_1.txt |
AC |
293 ms |
21628 KB |
subtask0_2.txt |
AC |
304 ms |
21596 KB |
subtask0_3.txt |
AC |
294 ms |
21624 KB |