結果

問題 No.150 "良問"(良問とは言っていない
ユーザー ki_ki33ki_ki33
提出日時 2015-02-13 00:29:03
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,901 bytes
コンパイル時間 2,576 ms
コンパイル使用メモリ 86,076 KB
実行使用メモリ 59,960 KB
最終ジャッジ日時 2023-09-06 00:26:10
合計ジャッジ時間 7,040 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 138 ms
55,840 KB
testcase_02 AC 138 ms
56,156 KB
testcase_03 AC 140 ms
56,504 KB
testcase_04 WA -
testcase_05 AC 143 ms
57,844 KB
testcase_06 AC 215 ms
57,820 KB
testcase_07 AC 139 ms
56,092 KB
testcase_08 AC 143 ms
55,992 KB
testcase_09 AC 144 ms
56,092 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 145 ms
55,776 KB
testcase_17 AC 148 ms
55,748 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentSkipListSet;

public class Main {
	public static final int C =  1000000007;
	static final int CY = 1000000000;
	//static boolean MAP[][];
	static int T;
	static int N;
	static double P;
	//static String S;
	static int M;
	static int MAX = -1;
	//static int tic[][];
	static String S[];
	static int Y[];
	static double W[];
	//static int max;
	static long DP[];
	static int ST[][];
	//static int p[];
	//static ArrayList<HashSet<Integer>> al;
	static ConcurrentSkipListSet<Integer> TS;
	static ArrayList<Integer> AL;
	//static int a[][];
	//static char[][] ch;
	//static ArrayList<HashMap<Long, Long>> al;
	//static String a[];
	//static String str;

	public static void main(String[] args) {
		StringBuilder sb = new StringBuilder();
		BufferedInputStream bs = new BufferedInputStream(System.in);
		Scanner sc = new Scanner(bs);



		T = sc.nextInt();
		
		S = new String[T];
		for (int i=0; i < T; i++) {
			S[i] = sc.next();
		}

		long[] ans = new long[T];
		
		
		for (int t=0; t < T; t++) {
			int[] good = new int[S[t].length()];
			int[] problem = new int[S[t].length()];
			
			for (int i=0; i < S[t].length(); i++) {
				if (S[t].length() - i < 11) {
					good[i] = -1;
				}else {
					int num = 0;
					if (S[t].charAt(i) == 'g') {
						num++;
					}
					if (S[t].charAt(i+1) == 'o') {
						num++;
					}
					if (S[t].charAt(i+2) == 'o') {
						num++;
					}
					if (S[t].charAt(i+3) == 'd') {
						num++;
					}
					good[i] = num;
				}
				if (i < 4|| S[t].length() - i < 7) {
					problem[i] = -1;
				}else {
					int num = 0;
					if (S[t].charAt(i) == 'p') {
						num++;
					}
					if (S[t].charAt(i+1) == 'r') {
						num++;
					}
					if (S[t].charAt(i+2) == 'o') {
						num++;
					}
					if (S[t].charAt(i+3) == 'b') {
						num++;
					}
					if (S[t].charAt(i+4) == 'l') {
						num++;
					}
					if (S[t].charAt(i+5) == 'e') {
						num++;
					}
					if (S[t].charAt(i+6) == 'm') {
						num++;
					}
					problem[i] = num;
				}
				
			}
			/*for (int i=0; i < S[t].length(); i++) {
				System.out.print(good[i] + ", ");
			}
			System.out.println();
			for (int i=0; i < S[t].length(); i++) {
				System.out.print(problem[i] + ", ");
			}
			System.out.println();
			*/
			int min = 10000;
			for (int i=0; i < S[t].length(); i++) {
				if (good[i] == -1)continue;
				int num = 4 - good[i];
				int max = 0;
				for (int v=i+1; v < S[t].length(); v++) {
					if (problem[v] == -1)continue;
					if (max < problem[v]) {
						max = problem[v];
					}
				}
				num += 7 - max;
				if (min > num) {
					min = num;
				}
			}
			ans[t] = min;
			
		}
		
		
		for (int i=0; i < T; i++) {
			sb.append(ans[i] + "\n");
		}
		System.out.print(sb);

	}


}
0