Submission #2235275


Source Code Expand

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int min = 114514;
		for(char c = 'a'; c <= 'z'; c++) {
			String ns = s;
			int count=0;
			while(!ns.matches("("+c+")*")) {
				count++;
				StringBuilder sb = new StringBuilder();
				for(int i = 0; i < ns.length()-1; i++) {
					if(ns.charAt(i)==c||ns.charAt(i+1)==c) {
						sb.append(c);
					} else {
						sb.append('P');
					}
				}
				ns = sb.toString();
			}
			min = Math.min(min, count);
		}
		System.out.println(min);
	}
}

Submission Info

Submission Time
Task A - Shrinking
User naoppy
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 623 Byte
Status AC
Exec Time 160 ms
Memory 27604 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 14
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 94 ms 18900 KB
0_01.txt AC 94 ms 18772 KB
0_02.txt AC 92 ms 19028 KB
0_03.txt AC 121 ms 21332 KB
1_00.txt AC 90 ms 21716 KB
1_01.txt AC 160 ms 27604 KB
1_02.txt AC 145 ms 24276 KB
1_03.txt AC 157 ms 23892 KB
1_04.txt AC 156 ms 23508 KB
1_05.txt AC 154 ms 26068 KB
1_06.txt AC 146 ms 23764 KB
1_07.txt AC 137 ms 23380 KB
1_08.txt AC 149 ms 24276 KB
1_09.txt AC 146 ms 23764 KB