結果

問題 No.150 "良問"(良問とは言っていない
ユーザー ki_ki33ki_ki33
提出日時 2015-02-13 00:47:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,894 bytes
コンパイル時間 2,402 ms
コンパイル使用メモリ 90,284 KB
実行使用メモリ 66,448 KB
最終ジャッジ日時 2023-09-06 00:28:47
合計ジャッジ時間 8,425 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
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)break;
				int num = 4 - good[i];
				int max = 0;
				for (int v=i+4; 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