Submission #1609105
Source Code Expand
import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().solve(); } void solve(){ Scanner sc=new Scanner(System.in); String s=sc.next(); int MinCount=100; for(int i=0;i<s.length();i++) { char target=s.charAt(i); String t2=s; int count=0; while(true) { String t1=""; for(int j=0;j<t2.length()-1;j++) { if(t2.charAt(j)==target) { t1+=t2.charAt(j); }else if(t2.charAt(j+1)==target){ t1+=t2.charAt(j+1); }else { t1+=t2.charAt(j); } } boolean flag=true; for(int j=0;j<t2.length()-1;j++) { if(t2.charAt(j)!=t2.charAt(j+1))flag=false; } if(flag)break; count++; t2=t1; } MinCount=Math.min(count, MinCount); } System.out.println(MinCount); } }
Submission Info
Submission Time | |
---|---|
Task | A - Shrinking |
User | kwkm0429 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 896 Byte |
Status | AC |
Exec Time | 242 ms |
Memory | 88164 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 89 ms | 21204 KB |
0_01.txt | AC | 87 ms | 19796 KB |
0_02.txt | AC | 89 ms | 19540 KB |
0_03.txt | AC | 95 ms | 23892 KB |
1_00.txt | AC | 88 ms | 18900 KB |
1_01.txt | AC | 242 ms | 88164 KB |
1_02.txt | AC | 112 ms | 23508 KB |
1_03.txt | AC | 138 ms | 37588 KB |
1_04.txt | AC | 153 ms | 41940 KB |
1_05.txt | AC | 155 ms | 43732 KB |
1_06.txt | AC | 160 ms | 43092 KB |
1_07.txt | AC | 136 ms | 42708 KB |
1_08.txt | AC | 205 ms | 58188 KB |
1_09.txt | AC | 226 ms | 68688 KB |