Submission #7388


Source Code Expand

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	
	public static void main(String[] args) throws IOException {
		BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.valueOf(s.readLine());
		String line = s.readLine();
		int len = line.length();

		
		char[] inputs = {'A', 'B', 'X', 'Y'};
		List<String> candidates = new ArrayList<String>();
		for (int i = 0 ; i < 4 ; i++) {
			for (int j = 0 ; j < 4 ; j++) {
				candidates.add("" + inputs[i] + inputs[j]);
			}
		}
		
		
		int min = len;
		for (String L : candidates) {
			for (String R : candidates) {
				String w = line.replace(L, "L").replace(R, "R");
				min = Math.min(w.length(), min);
			}
		}
		System.out.println(min);
	}
}

Submission Info

Submission Time
Task C - コマンド入力
User hamadu
Language Java (OpenJDK 1.7.0)
Score 100
Code Size 875 Byte
Status AC
Exec Time 563 ms
Memory 30788 KB

Judge Result

Set Name All
Score / Max Score 100 / 100
Status
AC × 45
Set Name Test Cases
All 00_retmax.txt, 00_retmin.txt, 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 02_twothree_00.txt, 02_twothree_01.txt, 02_twothree_02.txt, 02_twothree_03.txt, 02_twothree_04.txt, 02_twothree_05.txt, 02_twothree_06.txt, 02_twothree_07.txt, 02_twothree_08.txt, 02_twothree_09.txt, 02_twothree_10.txt, 02_twothree_11.txt, 02_twothree_12.txt, 02_twothree_13.txt, 02_twothree_14.txt, 02_twothree_15.txt, 02_twothree_16.txt, 02_twothree_17.txt, 02_twothree_18.txt, 02_twothree_19.txt
Case Name Status Exec Time Memory
00_retmax.txt AC 559 ms 24620 KB
00_retmin.txt AC 411 ms 20180 KB
00_sample_00.txt AC 405 ms 19828 KB
00_sample_01.txt AC 431 ms 21596 KB
00_sample_02.txt AC 459 ms 19880 KB
01_rnd_00.txt AC 506 ms 29136 KB
01_rnd_01.txt AC 549 ms 28712 KB
01_rnd_02.txt AC 506 ms 29424 KB
01_rnd_03.txt AC 500 ms 28764 KB
01_rnd_04.txt AC 502 ms 29016 KB
01_rnd_05.txt AC 520 ms 28612 KB
01_rnd_06.txt AC 515 ms 29932 KB
01_rnd_07.txt AC 506 ms 28832 KB
01_rnd_08.txt AC 509 ms 29632 KB
01_rnd_09.txt AC 510 ms 29000 KB
01_rnd_10.txt AC 516 ms 30788 KB
01_rnd_11.txt AC 563 ms 28764 KB
01_rnd_12.txt AC 514 ms 27296 KB
01_rnd_13.txt AC 511 ms 30076 KB
01_rnd_14.txt AC 507 ms 30504 KB
01_rnd_15.txt AC 483 ms 27696 KB
01_rnd_16.txt AC 493 ms 28048 KB
01_rnd_17.txt AC 550 ms 30200 KB
01_rnd_18.txt AC 499 ms 29136 KB
01_rnd_19.txt AC 557 ms 30344 KB
02_twothree_00.txt AC 523 ms 27796 KB
02_twothree_01.txt AC 491 ms 26156 KB
02_twothree_02.txt AC 541 ms 26312 KB
02_twothree_03.txt AC 502 ms 26432 KB
02_twothree_04.txt AC 493 ms 25864 KB
02_twothree_05.txt AC 497 ms 26692 KB
02_twothree_06.txt AC 547 ms 26988 KB
02_twothree_07.txt AC 500 ms 26988 KB
02_twothree_08.txt AC 502 ms 26948 KB
02_twothree_09.txt AC 488 ms 25680 KB
02_twothree_10.txt AC 541 ms 26144 KB
02_twothree_11.txt AC 510 ms 26204 KB
02_twothree_12.txt AC 504 ms 27228 KB
02_twothree_13.txt AC 500 ms 25524 KB
02_twothree_14.txt AC 499 ms 25676 KB
02_twothree_15.txt AC 490 ms 26028 KB
02_twothree_16.txt AC 497 ms 25052 KB
02_twothree_17.txt AC 497 ms 25988 KB
02_twothree_18.txt AC 505 ms 26556 KB
02_twothree_19.txt AC 495 ms 26452 KB